static VOID CALLBACK evfilt_timer_callback(void* param, BOOLEAN fired){ struct knote* kn; struct kqueue* kq; if(fired){ dbg_puts("called, but timer did not fire - this case should never be reached"); return; } assert(param); kn = (struct knote*)param; if(kn->kn_flags & KNFL_KNOTE_DELETED) { dbg_puts("knote marked for deletion, skipping event"); return; } else { kq = kn->kn_kq; assert(kq); if (!PostQueuedCompletionStatus(kq->kq_iocp, 1, (ULONG_PTR) 0, (LPOVERLAPPED) kn)) { dbg_lasterror("PostQueuedCompletionStatus()"); return; /* FIXME: need more extreme action */ } #if DEADWOOD evt_signal(kq->kq_loop, EVT_WAKEUP, kn); #endif } if(kn->kev.flags & EV_ONESHOT) { struct filter* filt; if( filter_lookup(&filt, kq, kn->kev.filter) ) dbg_perror("filter_lookup()"); knote_release(kn); } }
static void get_file_params(xml_data_node *node, const char **filename, const char **fork, filter_getinfoproc *filter) { xml_attribute_node *attr_node; *filename = NULL; *fork = NULL; *filter = NULL; attr_node = xml_get_attribute(node, "name"); if (!attr_node) { error_missingattribute("name"); return; } *filename = attr_node->value; attr_node = xml_get_attribute(node, "fork"); if (attr_node) *fork = attr_node->value; attr_node = xml_get_attribute(node, "filter"); if (attr_node) { *filter = filter_lookup(attr_node->value); if (!*filter) report_message(MSG_FAILURE, "Cannot find filter '%s'", attr_node->value); } }
static apr_status_t filter_harness(ap_filter_t *f, apr_bucket_brigade *bb) { apr_status_t ret; #ifndef NO_PROTOCOL const char *cachecontrol; char *str; #endif harness_ctx *ctx = f->ctx; ap_filter_rec_t *filter = f->frec; if (f->r->status != 200 && !apr_table_get(f->r->subprocess_env, "filter-errordocs")) { ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb); } filter_trace(f->c, filter->debug, f->frec->name, bb); /* look up a handler function if we haven't already set it */ if (!ctx->func) { #ifndef NO_PROTOCOL if (f->r->proxyreq) { if (filter->proto_flags & AP_FILTER_PROTO_NO_PROXY) { ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb); } if (filter->proto_flags & AP_FILTER_PROTO_TRANSFORM) { cachecontrol = apr_table_get(f->r->headers_out, "Cache-Control"); if (cachecontrol) { str = apr_pstrdup(f->r->pool, cachecontrol); ap_str_tolower(str); if (strstr(str, "no-transform")) { ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb); } } } } #endif if (!filter_lookup(f, filter)) { ap_remove_output_filter(f); return ap_pass_brigade(f->next, bb); } } /* call the content filter with its own context, then restore our * context */ f->ctx = ctx->fctx; ret = ctx->func(f, bb); ctx->fctx = f->ctx; f->ctx = ctx; return ret; }
static int parse_options(int argc, char *argv[], int minunnamed, int maxunnamed, option_resolution *resolution, filter_getinfoproc *filter, const char **fork) { int i; int lastunnamed = 0; char *s; char *name = NULL; char *value = NULL; optreserr_t oerr; static char buf[256]; if (filter) *filter = NULL; if (fork) *fork = NULL; for (i = 0; i < argc; i++) { /* Named or unamed arg */ if ((argv[i][0] != '-') || (argv[i][1] != '-')) { /* Unnamed */ if (i >= maxunnamed) goto error; /* Too many unnamed */ lastunnamed = i + 1; } else { /* Named */ name = argv[i] + 2; s = strchr(name, '='); if (!s) goto error; *s = 0; value = s + 1; if (!strcmp(name, "filter")) { /* filter option */ if (!filter) goto error; /* this command doesn't use filters */ if (*filter) goto optionalreadyspecified; *filter = filter_lookup(value); if (!(*filter)) goto filternotfound; } else if (!strcmp(name, "fork")) { /* fork option */ if (!fork) goto error; /* this command doesn't use filters */ if (*fork) goto optionalreadyspecified; snprintf(buf, ARRAY_LENGTH(buf), "%s", value); *fork = buf; } else { /* Other named option */ if (i < minunnamed) goto error; /* Too few unnamed */ oerr = option_resolution_add_param(resolution, name, value); if (oerr) goto opterror; } } } return lastunnamed; filternotfound: fprintf(stderr, "%s: Unknown filter type\n", value); return -1; optionalreadyspecified: fprintf(stderr, "Cannot specify multiple %ss\n", name); return -1; opterror: fprintf(stderr, "%s: %s\n", name, option_resolution_error_string(oerr)); return -1; error: fprintf(stderr, "%s: Unrecognized option\n", argv[i]); return -1; }
static int64_t _archive_filter_bytes(struct archive *_a, int n) { struct archive_write_filter *f = filter_lookup(_a, n); return f == NULL ? -1 : f->bytes_written; }
static const char * _archive_filter_name(struct archive *_a, int n) { struct archive_write_filter *f = filter_lookup(_a, n); return f == NULL ? NULL : f->name; }
static int _archive_filter_code(struct archive *_a, int n) { struct archive_write_filter *f = filter_lookup(_a, n); return f == NULL ? -1 : f->code; }