/** * Prepare reception of query hit data by building an appropriate RX stack. * * @return TRUE if we may continue with the download, FALSE if the search * was already closed in the GUI. */ gboolean browse_host_dl_receive( struct browse_ctx *bc, gnet_host_t *host, wrap_io_t *wio, const char *vendor, guint32 flags) { g_assert(bc != NULL); if (bc->closed) return FALSE; gnet_host_copy(&bc->host, host); bc->vendor = atom_str_get(vendor); /* * Freeing of the RX stack must be asynchronous: each time we establish * a new connection, dismantle the previous stack. Otherwise the RX * stack will be freed when the corresponding download structure is * reclaimed. */ if (bc->rx != NULL) { rx_free(bc->rx); bc->rx = NULL; } { struct rx_link_args args; args.cb = &browse_rx_link_cb; args.bws = bsched_in_select_by_addr(gnet_host_get_addr(&bc->host)); args.wio = wio; bc->rx = rx_make(bc, &bc->host, rx_link_get_ops(), &args); } if (flags & BH_DL_CHUNKED) { struct rx_chunk_args args; args.cb = &browse_rx_chunk_cb; bc->rx = rx_make_above(bc->rx, rx_chunk_get_ops(), &args); } if (flags & BH_DL_INFLATE) { struct rx_inflate_args args; args.cb = &browse_rx_inflate_cb; bc->rx = rx_make_above(bc->rx, rx_inflate_get_ops(), &args); } rx_set_data_ind(bc->rx, browse_data_ind); rx_enable(bc->rx); return TRUE; }
void mutt_free_spam_list (SPAM_LIST ** list) { SPAM_LIST *p; if (!list) return; while (*list) { p = *list; *list = (*list)->next; rx_free (&p->rx); mem_free(&p->template);
/** * Terminate THEX download. */ void thex_download_free(struct thex_download **ptr) { struct thex_download *ctx = *ptr; if (ctx) { if (ctx->rx) { rx_free(ctx->rx); ctx->rx = NULL; } HFREE_NULL(ctx->data); G_FREE_NULL(ctx->leaves); atom_sha1_free_null(&ctx->sha1); atom_tth_free_null(&ctx->tth); WFREE(ctx); *ptr = NULL; } }
/** * Terminate host browsing. */ void browse_host_dl_free(struct browse_ctx **ptr) { struct browse_ctx *bc = *ptr; if (bc) { atom_str_free_null(&bc->vendor); if (bc->rx) { rx_free(bc->rx); bc->rx = NULL; } if (!bc->closed) { search_dissociate_browse(bc->sh, bc->owner); } HFREE_NULL(bc->data); WFREE(bc); *ptr = NULL; } }
int rx_like_at_loc (int for_match, const char *file, int line, const char *got, const char *expected, const char *fmt, ...) { va_list args; int test; Rx *rx = rx_new(expected); if (!rx) exit(255); test = rx_match(rx, got) ^ !for_match; rx_free(rx); va_start(args, fmt); vok_at_loc(file, line, test, fmt, args); va_end(args); if (!test) { diag(" %13s '%s'", "", got); diag(" %13s: '%s'", for_match ? "doesn't match" : "matches", expected); } return test; }
rx_t *rx_compile (const char* pattern, buffer_t* error, int flags, int no) { int f = 0, err; rx_t *pp = mem_calloc (1, sizeof (rx_t)); /* map RX_* flags to REG_* flags */ f = posix_flags(flags); pp->pattern = str_dup (pattern); pp->no = no ? REG_NOMATCH : 0; pp->rx = mem_calloc (1, sizeof (regex_t)); if ((err = regcomp((regex_t*)pp->rx, NONULL(pattern), f)) != 0) { if (error) { /* * error may be initialized to {0,0,0} -> add something to have * some space for regerror() */ if (!error->size) buffer_add_ch(error,'\0'); regerror(err,pp->rx,error->str,error->size); } rx_free (pp); mem_free (&pp); } return pp; }
/** * Prepare reception of THEX data by building an appropriate RX stack. * * @return TRUE if we may continue with the download. */ bool thex_download_receive(struct thex_download *ctx, filesize_t content_length, gnet_host_t *host, struct wrap_io *wio, uint32 flags) { g_assert(ctx != NULL); gnet_host_copy(&ctx->host, host); /* * Freeing of the RX stack must be asynchronous: each time we establish * a new connection, dismantle the previous stack. Otherwise the RX * stack will be freed when the corresponding download structure is * reclaimed. */ if (ctx->rx != NULL) { rx_free(ctx->rx); ctx->rx = NULL; } /* * If there is a Content-Length indication in the HTTP reply, it is * supplied here and will be used as a limit of the data we'll read. * * If there was none (for instance if the output is chunked), then 0 * is given and we'll use a hardwired maximum. */ if (content_length > MAX_INT_VAL(size_t)) return FALSE; ctx->max_size = content_length ? (size_t) content_length : THEX_DOWNLOAD_MAX_SIZE; { struct rx_link_args args; args.cb = &thex_rx_link_cb; args.bws = bsched_in_select_by_addr(gnet_host_get_addr(&ctx->host)); args.wio = wio; ctx->rx = rx_make(ctx, &ctx->host, rx_link_get_ops(), &args); } if (flags & THEX_DOWNLOAD_F_CHUNKED) { struct rx_chunk_args args; args.cb = &thex_rx_chunk_cb; ctx->rx = rx_make_above(ctx->rx, rx_chunk_get_ops(), &args); } if (flags & THEX_DOWNLOAD_F_INFLATE) { struct rx_inflate_args args; args.cb = &thex_rx_inflate_cb; ctx->rx = rx_make_above(ctx->rx, rx_inflate_get_ops(), &args); } rx_set_data_ind(ctx->rx, thex_download_data_ind); rx_enable(ctx->rx); return TRUE; }