void *harvest_http_go_proc(void *arg) { task_t *t = (task_t *) arg; int fd = (int)TASK_DATA(t), rv; unsigned inlen, outlen; UINT32 distlen=0; C_DistillerType type; char *inbuf=NULL, *outbuf=NULL, *distbuf=NULL; if (do_http_client_receive(fd, &inlen, &inbuf) != 0) { close(fd); return (void *) 0; } if (inlen <= 0) { close(fd); return (void *) 0; } if (Clib_Lowlevel_Op(inbuf, inlen, &outbuf, &outlen) != CLIB_OK) { if (inbuf) free(inbuf); if (outbuf) free(outbuf); close(fd); return (void *) 0; } strcpy(type.string, "all/passthru"); if (Distill(&type, 0, 0, outbuf, outlen, (void**) &distbuf, &distlen) != distOk) { if (inbuf) free(inbuf); if (outbuf) free(outbuf); close(fd); return (void *) 0; } if ((rv = correct_write(fd, distbuf, distlen)) != outlen) { if (inbuf) free(inbuf); if (outbuf) free(outbuf); FreeOutputBuffer(distbuf); close(fd); return (void *) 0; } if (inbuf) free(inbuf); if (outbuf) free(outbuf); FreeOutputBuffer(distbuf); close(fd); return (void *) 0; }
OMX_ERRORTYPE VideoFilter::DoFreeBuffer(OMX_PTR buffer,OMX_U32 nPortIndex) { if(nPortIndex == IN_PORT) FreeInputBuffer(buffer); if(nPortIndex == OUT_PORT) FreeOutputBuffer(buffer); return OMX_ErrorNone; }
void * file_go_proc(task_t *t) { FILE *htmlfile = (FILE *)(TASK_DATA(t)); C_DistillerType type; Argument ar; size_t inbufsize; UINT32 outbufsize; DistillerStatus status; char *inbuf; char *outbuf; struct stat s; /* get file size */ (void)fstat(fileno(htmlfile), &s); /* allocate input buffer */ inbufsize = s.st_size; assert(inbuf = (char *)MALLOC(inbufsize)); inbufsize = fread((void *)inbuf, sizeof(char), (size_t)inbufsize, htmlfile); fclose(htmlfile); SET_DISTILLER_TYPE(type, "text/html"); SET_ARG_ID(ar, 1); /* string that will be appended to each target URL in html file */ SET_ARG_STRING(ar, "__foo__"); /* call html distiller */ status = Distill(type, &ar, 1, (void *)inbuf, (UINT32)inbufsize, (void *)&outbuf, &outbufsize); proxy_debug_3(DBG_HTTP, "Distiller status = %d\n", (int)status); /* dump outbuf to a file */ #if 0 if (status == distOk) { assert(htmlfile = fopen("/tmp/foo", "w")); fwrite((void *)outbuf, sizeof(char), (size_t)outbufsize, htmlfile); fclose(htmlfile); } #endif FREE((void *)inbuf); FreeOutputBuffer((void *)outbuf); return (void *)0; }