STATIC char * S_filter_gets(pTHX_ register SV *sv, register PerlIO *fp, STRLEN append) { #ifdef PERL_CR_FILTER if (!PL_rsfp_filters) { filter_add(S_cr_textfilter,NULL); } #endif if (PL_rsfp_filters) { if (!append) SvCUR_set(sv, 0); /* start with empty line */ if (FILTER_READ(0, sv, 0) > 0) return ( SvPVX(sv) ) ; else return Nullch ; } else return (sv_gets(sv, fp, append)); }
cdk_error_t cdk_stream_set_cipher_flag( cdk_stream_t s, cdk_dek_t dek, int use_mdc ) { struct stream_filter_s * f; if( !s ) return CDK_Inv_Value; f = filter_add( s, _cdk_filter_cipher, fCIPHER ); if( !f ) return CDK_Out_Of_Core; dek->use_mdc = use_mdc; f->ctl = stream_get_mode( s ); f->u.cfx.dek = dek; f->u.cfx.mdc_method = use_mdc? GCRY_MD_SHA1 : 0; if( s->blkmode ) { f->u.cfx.blkmode.on = 1; f->u.cfx.blkmode.size = s->blkmode; } return 0; }
/** * cdk_stream_set_text_flag: * @s: the stream object * @lf: line ending * * Pushes the text filter to store the stream data in cannoncial format. **/ cdk_error_t cdk_stream_set_text_flag (cdk_stream_t s, const char *lf) { struct stream_filter_s *f; if (!s) { gnutls_assert (); return CDK_Inv_Value; } f = filter_add (s, _cdk_filter_text, fTEXT); if (!f) { gnutls_assert (); return CDK_Out_Of_Core; } f->ctl = stream_get_mode (s); f->u.tfx.lf = lf; return 0; }
/** * cdk_stream_set_armor_flag: * @s: the stream object * @type: the type of armor to use * * If the file is in read-mode, no armor type needs to be * defined (armor_type=0) because the armor filter will be * used for decoding existing armor data. * For the write mode, @armor_type can be set to any valid * armor type (message, key, sig). **/ cdk_error_t cdk_stream_set_armor_flag (cdk_stream_t s, int armor_type) { struct stream_filter_s *f; if (!s) { gnutls_assert (); return CDK_Inv_Value; } f = filter_add (s, _cdk_filter_armor, fARMOR); if (!f) { gnutls_assert (); return CDK_Out_Of_Core; } f->u.afx.idx = f->u.afx.idx2 = armor_type; f->ctl = stream_get_mode (s); return 0; }
PRIVATE int parseFilter(am_filters *patlist, const char* match) { char *line = NULL, *option = NULL, *param = NULL; char *saveptr; char *str = NULL; am_filter filter = NULL; int result = SUCCESS; /* be optimistic */ str = shorten(match); line = strtok_r(str, AM_DELIMITER, &saveptr); while (line) { if(!filter) { filter = filter_new(); assert(filter && "filter_new() failed!"); } if(parseSubOption(line, &option, ¶m) == 0) { if(!strncmp(option, "pattern", 7)) { filter->pattern = shorten(param); } else if(!strncmp(option, "useragent", 9)) { filter->agent = shorten(param); } else { dbg_printf(P_ERROR, "Unknown suboption '%s'!", option); } am_free(option); am_free(param); } else { dbg_printf(P_ERROR, "Invalid suboption string: '%s'!", line); } line = strtok_r(NULL, AM_DELIMITER, &saveptr); } if(filter && filter->pattern) { filter_add(filter, patlist); } else { dbg_printf(P_ERROR, "Invalid filter: '%s'", str); result = FAILURE; } am_free(str); return result; }
/** * cdk_stream_set_compress_flag: * @s: the stream object * @algo: the compression algo * @level: level of compression (0..9) * * In read mode it kicks off the decompression filter to retrieve * the uncompressed data. * In write mode the stream data will be compressed with the * given algorithm at the given level. **/ cdk_error_t cdk_stream_set_compress_flag (cdk_stream_t s, int algo, int level) { gnutls_assert (); return CDK_Not_Implemented; #if 0 struct stream_filter_s *f; if (!s) return CDK_Inv_Value; f = filter_add (s, _cdk_filter_compress, fCOMPRESS); if (!f) return CDK_Out_Of_Core; f->ctl = stream_get_mode (s); f->u.zfx.algo = algo; f->u.zfx.level = level; return 0; #endif }
static void set_filter(const struct cmdinfo *cip, const char *value) { filter_add(value, cip->arg_int); }
void filter_parse(const gchar *text) { const gchar *p; gchar *key; gchar *ext; gchar *desc; gint enabled = TRUE; if (!text || text[0] != '"') return; key = quoted_value(text); if (!key) return; p = text; p++; while (*p != '"' && *p != '\0') p++; if (*p != '"') { g_free(key); return; } p++; while (*p != '"' && *p != '\0') p++; if (*p != '"') { g_free(key); return; } ext = quoted_value(p); p++; while (*p != '"' && *p != '\0') p++; if (*p == '"') p++; while (*p != '"' && *p != '\0') p++; if (*p == '"') { desc = quoted_value(p); } else { desc = NULL; } if (key && key[0] == '#') { gchar *tmp; tmp = g_strdup(key + 1); g_free(key); key = tmp; enabled = FALSE; } if (key && strlen(key) > 0 && ext) filter_add(key, desc, ext, enabled); g_free(key); g_free(ext); g_free(desc); }