Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
libsed.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005, 2008 Sun Microsystems, Inc. All Rights Reserved.
3  * Use is subject to license terms.
4  *
5  * Copyright (c) 1984 AT&T
6  * All Rights Reserved
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * http://www.apache.org/licenses/LICENSE-2.0.
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
16  * or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef LIBSED_H
22 #define LIBSED_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <limits.h>
29 
30 #include "apr_file_io.h"
31 
32 #define SED_NLINES 256
33 #define SED_DEPTH 20
34 #define SED_LABSIZE 50
35 #define SED_ABUFSIZE 20
36 
37 typedef struct sed_reptr_s sed_reptr_t;
38 
39 struct sed_reptr_s {
41  char *ad1;
42  char *ad2;
43  char *re1;
45  char *rhs;
46  int findex;
47  char command;
48  int gfl;
49  char pfl;
50  char negfl;
51  int nrep;
52 };
53 
54 typedef struct sed_label_s sed_label_t;
55 
56 struct sed_label_s {
57  char asc[9];
60 };
61 
62 typedef apr_status_t (sed_err_fn_t)(void *data, const char *error);
63 typedef apr_status_t (sed_write_fn_t)(void *ctx, char *buf, int sz);
64 
66 #define NWFILES 11 /* 10 plus one for standard output */
67 
70  void *data;
71 
72  unsigned lsize;
73  char *linebuf;
74  char *lbend;
75  const char *saveq;
76 
77  char *cp;
78  char *lastre;
79  char *respace;
80  char sseof;
81  char *reend;
82  const char *earg;
83  int eflag;
84  int gflag;
85  int nflag;
87  int nlno;
88  int depth;
89 
90  char *fname[NWFILES];
91  int nfiles;
92 
97 
102  int nrep;
105 };
106 
107 typedef struct sed_eval_s sed_eval_t;
108 
109 struct sed_eval_s {
112  void *data;
113 
115 
117  void *fout;
118 
119  unsigned lsize;
120  char *linebuf;
121  char *lspend;
122 
123  unsigned hsize;
124  char *holdbuf;
125  char *hspend;
126 
127  unsigned gsize;
128  char *genbuf;
129  char *lcomend;
130 
135  unsigned char *inar;
136  int nrep;
137 
138  int dolflag;
139  int sflag;
140  int jflag;
141  int delflag;
143  int quitflag;
145  int numpass;
147  int col;
149 };
150 
151 apr_status_t sed_init_commands(sed_commands_t *commands, sed_err_fn_t *errfn, void *data,
152  apr_pool_t *p);
153 apr_status_t sed_compile_string(sed_commands_t *commands, const char *s);
155 char* sed_get_finalize_error(const sed_commands_t *commands, apr_pool_t* pool);
156 int sed_canbe_finalized(const sed_commands_t *commands);
157 void sed_destroy_commands(sed_commands_t *commands);
158 
160  sed_err_fn_t *errfn, void *data,
161  sed_write_fn_t *writefn, apr_pool_t *p);
162 apr_status_t sed_reset_eval(sed_eval_t *eval, sed_commands_t *commands, sed_err_fn_t *errfn, void *data);
163 apr_status_t sed_eval_buffer(sed_eval_t *eval, const char *buf, int bufsz, void *fout);
164 apr_status_t sed_eval_file(sed_eval_t *eval, apr_file_t *fin, void *fout);
166 void sed_destroy_eval(sed_eval_t *eval);
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 
172 #endif /* LIBSED_H */
Definition: libsed.h:68
Definition: libsed.h:39
char negfl
Definition: libsed.h:50
void * fout
Definition: libsed.h:117
int delflag
Definition: libsed.h:141
int nullmatch
Definition: libsed.h:146
char command
Definition: libsed.h:47
int nrep
Definition: libsed.h:102
Definition: libsed.h:56
char * lbend
Definition: libsed.h:74
Definition: apr_arch_file_io.h:107
sed_label_t * labend
Definition: libsed.h:96
unsigned gsize
Definition: libsed.h:127
const char * saveq
Definition: libsed.h:75
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
sed_reptr_t ** aptr
Definition: libsed.h:133
int findex
Definition: libsed.h:46
apr_status_t sed_init_eval(sed_eval_t *eval, sed_commands_t *commands, sed_err_fn_t *errfn, void *data, sed_write_fn_t *writefn, apr_pool_t *p)
sed_reptr_t * rep
Definition: libsed.h:101
char sseof
Definition: libsed.h:80
apr_status_t sed_finalize_eval(sed_eval_t *eval, void *f)
char * sed_get_finalize_error(const sed_commands_t *commands, apr_pool_t *pool)
char * ad1
Definition: libsed.h:41
sed_label_t * lab
Definition: libsed.h:95
char * ad2
Definition: libsed.h:42
char * lcomend
Definition: libsed.h:129
apr_int64_t lnum
Definition: libsed.h:116
void sed_destroy_eval(sed_eval_t *eval)
sed_reptr_t * ptrspace
Definition: libsed.h:99
char * fname[NWFILES]
Definition: libsed.h:90
int eflag
Definition: libsed.h:83
int dolflag
Definition: libsed.h:138
int col
Definition: libsed.h:147
char * genbuf
Definition: libsed.h:128
APR File I/O Handling.
int nrep
Definition: libsed.h:136
apr_status_t( sed_err_fn_t)(void *data, const char *error)
Definition: libsed.h:62
int nrep
Definition: libsed.h:51
apr_status_t sed_compile_file(sed_commands_t *commands, apr_file_t *fin)
sed_write_fn_t * writefn
Definition: libsed.h:111
apr_status_t sed_eval_buffer(sed_eval_t *eval, const char *buf, int bufsz, void *fout)
int nflag
Definition: libsed.h:85
int nlno
Definition: libsed.h:87
sed_reptr_t * address
Definition: libsed.h:59
sed_commands_t * commands
Definition: libsed.h:114
char * rhs
Definition: libsed.h:45
unsigned hsize
Definition: libsed.h:123
apr_int64_t tlno[SED_NLINES]
Definition: libsed.h:86
sed_reptr_t ** cmpend[SED_DEPTH]
Definition: libsed.h:98
unsigned char * inar
Definition: libsed.h:135
unsigned lsize
Definition: libsed.h:119
#define SED_ABUFSIZE
Definition: libsed.h:35
char * cp
Definition: libsed.h:77
void * data
Definition: libsed.h:112
#define SED_LABSIZE
Definition: libsed.h:34
sed_reptr_t * chain
Definition: libsed.h:58
sed_label_t * labtab
Definition: libsed.h:94
apr_status_t sed_reset_eval(sed_eval_t *eval, sed_commands_t *commands, sed_err_fn_t *errfn, void *data)
sed_err_fn_t * errfn
Definition: libsed.h:69
int sed_canbe_finalized(const sed_commands_t *commands)
char * respace
Definition: libsed.h:79
apr_pool_t * p
int canbefinal
Definition: libsed.h:104
sed_reptr_t * lb1
Definition: libsed.h:44
#define NWFILES
Definition: libsed.h:66
char * holdbuf
Definition: libsed.h:124
int nfiles
Definition: libsed.h:91
int finalflag
Definition: libsed.h:144
int gfl
Definition: libsed.h:48
int sflag
Definition: libsed.h:139
#define SED_NLINES
Definition: libsed.h:32
sed_reptr_t * next
Definition: libsed.h:40
char * lastre
Definition: libsed.h:78
apr_pool_t * pool
Definition: libsed.h:148
apr_status_t sed_eval_file(sed_eval_t *eval, apr_file_t *fin, void *fout)
unsigned lsize
Definition: libsed.h:72
Definition: libsed.h:109
char * lspend
Definition: libsed.h:121
char pfl
Definition: libsed.h:49
const char * earg
Definition: libsed.h:82
char * hspend
Definition: libsed.h:125
char asc[9]
Definition: libsed.h:57
sed_reptr_t * pending
Definition: libsed.h:134
long apr_int64_t
Definition: apr.h:371
apr_status_t sed_init_commands(sed_commands_t *commands, sed_err_fn_t *errfn, void *data, apr_pool_t *p)
int depth
Definition: libsed.h:88
char * re1
Definition: libsed.h:43
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
apr_status_t sed_compile_string(sed_commands_t *commands, const char *s)
char * linebuf
Definition: libsed.h:73
int apr_status_t
Definition: apr_errno.h:44
apr_pool_t * pool
Definition: libsed.h:103
#define SED_DEPTH
Definition: libsed.h:33
void sed_destroy_commands(sed_commands_t *commands)
sed_reptr_t * ptrend
Definition: libsed.h:100
apr_file_t * fcode[NWFILES]
Definition: libsed.h:131
sed_reptr_t * abuf[SED_ABUFSIZE]
Definition: libsed.h:132
void * data
Definition: libsed.h:70
sed_label_t ltab[SED_LABSIZE]
Definition: libsed.h:93
int lreadyflag
Definition: libsed.h:142
int jflag
Definition: libsed.h:140
int quitflag
Definition: libsed.h:143
int gflag
Definition: libsed.h:84
sed_err_fn_t * errfn
Definition: libsed.h:110
char * reend
Definition: libsed.h:81
apr_status_t( sed_write_fn_t)(void *ctx, char *buf, int sz)
Definition: libsed.h:63
char * linebuf
Definition: libsed.h:120
int numpass
Definition: libsed.h:145