Version 2.9.4 checkin.
[privoxy.git] / pcrs.h
1 #ifndef _PCRS_H
2 #define _PCRS_H
3
4 /*********************************************************************
5  *
6  * File        :  $Source: /home/administrator/cvs/ijb/pcrs.h,v $
7  *
8  * Purpose     :  This is the pre-pre-alpha realease of libpcrs. It is only
9  *                published at this (ugly) stage of development, because it is
10  *                needed for a new feature in JunkBuster.
11  *
12  *                Apart from the code being quite a mess, no inconsistencies,
13  *                memory leaks or functional bugs **should** be present.
14  *
15  *                While you ROTFL at the code, you could just as well mail me
16  *                (oes@paradis.rhein.de) with advice for improvement.
17  *
18  *                pcrs is a supplement to the brilliant pcre library by Philip
19  *                Hazel (ph10@cam.ac.uk) and adds Perl-style substitution. That
20  *                is, it mimics Perl's 's' operator.
21  *
22  *                Currently, there's no documentation besides comments and the
23  *                source itself ;-)
24  *
25  * Copyright   :  Written and copyright 2001 by Sourceforge IJBSWA team.
26  *
27  * Revisions   :
28  *    $Log: pcrs.h,v $
29  *    Revision 1.4  2001/05/11 01:57:02  rodney
30  *    Added new file header standard w/RCS control tags.
31  *
32  *    revision 1.3  2001/05/08 02:38:13  rodney
33  *    Changed C++ "//" style comment to C style comments.
34  *
35  *    revision 1.2  2001/04/30 02:39:24  rodney
36  *    Made this pcrs.h file conditionally included.
37  *
38  *    revision 1.1  2001/04/16 21:10:38  rodney
39  *    Initial checkin
40  *
41  *********************************************************************/
42
43 #define PCRS_H_VERSION "$Id: pcrs.h,v 1.1 2001/05/13 21:57:07 administrator Exp $"
44 \f
45
46
47 #include <pcre.h>
48
49 #define FALSE 0
50 #define TRUE 1
51 #define PCRS_MAX_MATCHES 300
52 #define PCRS_MAX_SUBMATCHES 33
53 #define CHARBUFSIZ BUFSIZ * sizeof(char)
54
55 #define PCRS_ERR_NOMEM     -10      /* Failed to acquire memory. */
56 #define PCRS_ERR_CMDSYNTAX -11      /* Syntax of s///-command */
57 #define PCRS_ERR_STUDY     -12      /* pcre error while studying the pattern */
58
59 typedef struct S_PCRS_SUBSTITUTE {
60   char *text;
61   int backrefs;
62   int block_offset[PCRS_MAX_SUBMATCHES];
63   int block_length[PCRS_MAX_SUBMATCHES];
64   int backref[PCRS_MAX_SUBMATCHES];
65   int backref_count[PCRS_MAX_SUBMATCHES];
66 } pcrs_substitute;
67
68 typedef struct S_PCRS_MATCH {
69   /* char *buffer; */
70   int submatches;
71   int submatch_offset[PCRS_MAX_SUBMATCHES];
72   int submatch_length[PCRS_MAX_SUBMATCHES];
73 } pcrs_match;
74
75 typedef struct S_PCRS_JOB {
76   pcre *pattern;
77   pcre_extra *hints;
78   int options;
79   int globalflag;
80   int successflag;
81   pcrs_substitute *substitute;
82   struct S_PCRS_JOB *next;
83 } pcrs_job;
84
85 extern int              pcrs_compile_perl_options(char *optstring, int *globalflag);
86 extern pcrs_substitute *pcrs_compile_replacement(char *replacement, int *errptr);
87 extern pcrs_job        *pcrs_free_job(pcrs_job *job);
88 extern pcrs_job        *pcrs_make_job(char *command, int *errptr);
89 extern pcrs_job        *create_pcrs_job(pcre *pattern, pcre_extra *hints, int options, int globalflag, pcrs_substitute *substitute, int *errptr);
90 extern int              pcrs_exec_substitution(pcrs_job *job, char *subject, int subject_length, char **result, int *result_length);
91
92
93 #endif /* ndef _PCRS_H */
94
95 /*
96   Local Variables:
97   tab-width: 3
98   end:
99 */