Example #1
0
void
rendertext(URLwin *u, Bytes *b)
{
	Rune *rurl;

	rurl = toStr((uchar*)u->url, strlen(u->url), UTF_8);
	u->items = parsehtml(b->b, b->n, rurl, u->type, UTF_8, &u->docinfo);
//	free(rurl);

	rerender(u);
}
Example #2
0
void
rendertext(URLwin *u, Bytes *b)
{
	Rune *rurl;

	rurl = toStr((uchar*)u->url, strlen(u->url), ISO_8859_1);
	u->items = parsehtml(b->b, b->n, rurl, u->type, charset((char*)b->b), &u->docinfo);
/*	free(rurl); */

	rerender(u);
}
Example #3
0
static
void
pageloadproc(void *v)
{
	Page *p;
	char buf[BUFSIZE], *s;
	int32_t n, l;
	int fd, i, ctype;

	threadsetname("pageloadproc");
	rfork(RFFDG);

	p = v;
	addrefresh(p, "opening: %S...", p->url->src.r);
	fd = urlopen(p->url);
	if(fd < 0){
		addrefresh(p, "%S: %r", p->url->src.r);
    Err:
		p->loading = FALSE;
		return;
	}
	if(runestrlen(p->url->ctype.r) == 0) /* assume .html when headers don't say anyting */
		goto Html;

	snprint(buf, sizeof(buf), "%S", p->url->ctype.r);
	for(i=0; mimetab[i]!=nil; i++)
		if(cistrncmp(buf, mimetab[i], strlen(mimetab[i])) == 0)
			break;

	if(mimetab[i]){
    Html:
		ctype = TextHtml;
	}else if(cistrncmp(buf, "text/", 5) == 0)
		ctype = TextPlain;
	else{
		close(fd);
		addrefresh(p, "%S: unsupported mime type: '%S'", p->url->act.r, p->url->ctype.r);
		goto Err;
	}
	addrefresh(p, "loading: %S...", p->url->src.r);
	s = nil;
	l = 0;
	while((n=read(fd, buf, sizeof(buf))) > 0){
		if(p->aborting){
			if(s){
				free(s);
				s = nil;
			}
			break;
		}
		s = erealloc(s, l+n+1);
		memmove(s+l, buf, n);
		l += n;
		s[l] = '\0';
	}
	close(fd);
	n = l;
	if(s){
		s = convert(p->url->ctype, s, &n);
		p->items = parsehtml((uint8_t *)s, n, p->url->act.r, ctype,
				     UTF_8, &p->doc);
		free(s);
		fixtext(p);
		if(ctype==TextHtml && p->aborting==FALSE){
			p->changed = TRUE;
			addrefresh(p, "");
			if(p->doc->doctitle){
				p->title.r = erunestrdup(p->doc->doctitle);
				p->title.nr = runestrlen(p->title.r);
			}
			p->loading = XXX;
			if(p->doc->kidinfo)
				loadchilds(p, p->doc->kidinfo);
			else if(p->doc->images)
				loadimages(p);
		}
	}
	p->changed = TRUE;
	p->loading = FALSE;
	addrefresh(p, "");
}
Example #4
0
int main(int argc, char* argv[])
{
    codecs_t *cl;
    FILE *f1;
    FILE *f2;
    int c,d,i;
    int pos;
    int section=-1;
    int nr_codecs;
    int win32=-1;
    int dshow=-1;
    int win32ex=-1;

    /*
     * Take path to codecs.conf from command line, or fall back on
     * etc/codecs.conf
     */
    if (!(nr_codecs = parse_codec_cfg((argc>1)?argv[1]:"etc/codecs.conf")))
        exit(1);
    if (codecs_conf_release < CODEC_CFG_MIN)
        exit(1);

    if (argc > 1) {
        int i, j;
        const char* nm[2];
        codecs_t* cod[2];
        int nr[2];

        nm[0] = "builtin_video_codecs";
        cod[0] = video_codecs;
        nr[0] = nr_vcodecs;

        nm[1] = "builtin_audio_codecs";
        cod[1] = audio_codecs;
        nr[1] = nr_acodecs;

        printf("/* GENERATED FROM %s, DO NOT EDIT! */\n\n",argv[1]);
        printf("#include <stddef.h>\n");
        printf("#include \"codec-cfg.h\"\n\n");
        printf("#define CODEC_CFG_MIN %i\n\n", codecs_conf_release);

        for (i=0; i<2; i++) {
            printf("const codecs_t %s[] = {\n", nm[i]);
            for (j = 0; j < nr[i]; j++) {
                printf("{");

                print_int_array(cod[i][j].fourcc, CODECS_MAX_FOURCC);
                printf(", /* fourcc */\n");

                print_int_array(cod[i][j].fourccmap, CODECS_MAX_FOURCC);
                printf(", /* fourccmap */\n");

                print_int_array(cod[i][j].outfmt, CODECS_MAX_OUTFMT);
                printf(", /* outfmt */\n");

                print_char_array(cod[i][j].outflags, CODECS_MAX_OUTFMT);
                printf(", /* outflags */\n");

                print_int_array(cod[i][j].infmt, CODECS_MAX_INFMT);
                printf(", /* infmt */\n");

                print_char_array(cod[i][j].inflags, CODECS_MAX_INFMT);
                printf(", /* inflags */\n");

                print_string(cod[i][j].name);    printf(", /* name */\n");
                print_string(cod[i][j].info);    printf(", /* info */\n");
                print_string(cod[i][j].comment); printf(", /* comment */\n");
                print_string(cod[i][j].dll);     printf(", /* dll */\n");
                print_string(cod[i][j].drv);     printf(", /* drv */\n");

                printf("{ 0x%08lx, %hu, %hu,",
                       cod[i][j].guid.f1,
                       cod[i][j].guid.f2,
                       cod[i][j].guid.f3);
                print_char_array(cod[i][j].guid.f4, sizeof(cod[i][j].guid.f4));
                printf(" }, /* GUID */\n");
                printf("%hd /* flags */, %hd /* status */, %hd /* cpuflags */ }\n",
                       cod[i][j].flags,
                       cod[i][j].status,
                       cod[i][j].cpuflags);
                if (j < nr[i]) printf(",\n");
            }
            printf("};\n\n");
        }
        exit(0);
    }

    f1=fopen("DOCS/tech/codecs-in.html","rb"); if(!f1) exit(1);
    f2=fopen("DOCS/codecs-status.html","wb"); if(!f2) exit(1);

    while((c=fgetc(f1))>=0){
        if(c!='%'){
            fputc(c,f2);
            continue;
        }
        d=fgetc(f1);
        if(d>='0' && d<='9'){
            // begin section
            section=d-'0';
            //printf("BEGIN %d\n",section);
            if(section>=5){
                // audio
                cl = audio_codecs;
                nr_codecs = nr_acodecs;
                dshow=7;win32=4;
            } else {
                // video
                cl = video_codecs;
                nr_codecs = nr_vcodecs;
                dshow=4;win32=2;win32ex=6;
            }
            pos=ftell(f1);
            for(i=0;i<nr_codecs;i++){
                fseek(f1,pos,SEEK_SET);
                switch(section){
                case 0:
                case 5:
                    if(cl[i].status==CODECS_STATUS_WORKING)
//                if(!(!strcmp(cl[i].drv,"vfw") || !strcmp(cl[i].drv,"dshow") || !strcmp(cl[i].drv,"vfwex") || !strcmp(cl[i].drv,"acm")))
                        parsehtml(f1,f2,&cl[i]);
                    break;
#if 0
                case 1:
                case 6:
                    if(cl[i].status==CODECS_STATUS_WORKING)
                        if((!strcmp(cl[i].drv,"vfw") || !strcmp(cl[i].drv,"dshow") || !strcmp(cl[i].drv,"vfwex") || !strcmp(cl[i].drv,"acm")))
                            parsehtml(f1,f2,&cl[i]);
                    break;
#endif
                case 2:
                case 7:
                    if(cl[i].status==CODECS_STATUS_PROBLEMS)
                        parsehtml(f1,f2,&cl[i]);
                    break;
                case 3:
                case 8:
                    if(cl[i].status==CODECS_STATUS_NOT_WORKING)
                        parsehtml(f1,f2,&cl[i]);
                    break;
                case 4:
                case 9:
                    if(cl[i].status==CODECS_STATUS_UNTESTED)
                        parsehtml(f1,f2,&cl[i]);
                    break;
                default:
                    printf("Warning! unimplemented section: %d\n",section);
                }
            }
            fseek(f1,pos,SEEK_SET);
            skiphtml(f1);

            continue;
        }
        fputc(c,f2);
        fputc(d,f2);
    }

    fclose(f2);
    fclose(f1);
    return 0;
}