sed1.c revision 5bfaaf573bacb45c1cf290ce85ecc676587e8a64
/*
* Copyright (c) 2005, 2008 Sun Microsystems, Inc. All Rights Reserved.
* Use is subject to license terms.
*
* Copyright (c) 1984 AT&T
* All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "apr.h"
#include "apr_lib.h"
#include "libsed.h"
#include "sed.h"
#include "apr_strings.h"
#include "regexp.h"
char *trans[040] = {
"\\01",
"\\02",
"\\03",
"\\04",
"\\05",
"\\06",
"\\07",
"\\10",
"\\11",
"\n",
"\\13",
"\\14",
"\\15",
"\\16",
"\\17",
"\\20",
"\\21",
"\\22",
"\\23",
"\\24",
"\\25",
"\\26",
"\\27",
"\\30",
"\\31",
"\\32",
"\\33",
"\\34",
"\\35",
"\\36",
"\\37"
};
char rub[] = {"\\177"};
{
const char* error;
}
}
#define INIT_BUF_SIZE 1024
/*
* grow_buffer
*/
unsigned int newsize)
{
int spendsize = 0;
return;
/* Avoid number of times realloc is called. It could cause huge memory
* requirement if line size is huge e.g 2 MB */
}
/* Align it to 4 KB boundary */
}
}
}
}
/*
* grow_line_buffer
*/
{
}
/*
* grow_hold_buffer
*/
{
}
/*
* grow_gen_buffer
*/
char **gspend)
{
}
}
/*
* appendmem_to_linebuf
*/
{
}
}
/*
* append_to_linebuf
*/
{
/* Copy string including null character */
}
/*
* copy_to_linebuf
*/
{
}
/*
* append_to_holdbuf
*/
{
}
/* hspend will now point to NULL character */
}
/*
* copy_to_holdbuf
*/
{
}
/*
* append_to_genbuf
*/
{
}
/* *gspend will now point to NULL character */
}
/*
* copy_to_genbuf
*/
{
}
}
/*
* sed_init_eval
*/
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_reset_eval
*/
apr_status_t sed_reset_eval(sed_eval_t *eval, sed_commands_t *commands, sed_err_fn_t *errfn, void *data)
{
int i;
}
}
}
eval->lreadyflag = 0;
return APR_EGENERAL;
}
}
return APR_SUCCESS;
}
/*
* sed_destroy_eval
*/
{
int i;
/* eval->linebuf, eval->holdbuf, eval->genbuf and eval->inar are allocated
* on pool. It will be freed when pool will be freed */
}
}
}
/*
* sed_eval_file
*/
{
for (;;) {
char buf[1024];
apr_size_t read_bytes = 0;
read_bytes = sizeof(buf);
break;
return APR_EGENERAL;
return APR_SUCCESS;
}
}
/*
* sed_eval_buffer
*/
{
return APR_SUCCESS;
/* Commands were not finalized properly. */
if (error) {
return APR_EGENERAL;
}
}
/* Process leftovers */
eval->lreadyflag = 0;
if (rv != APR_SUCCESS)
return rv;
}
while (bufsz) {
char *n;
int llen;
if (n == NULL)
break;
/* This might be the last line; delay its processing */
break;
}
/* replace new line character with NULL */
if (rv != APR_SUCCESS)
return rv;
break;
}
/* Save the leftovers for later */
if (bufsz) {
}
return APR_SUCCESS;
}
/*
* sed_finalize_eval
*/
{
return APR_SUCCESS;
/* Process leftovers */
if (eval->lreadyflag) {
eval->lreadyflag = 0;
} else {
/* Code can probably reach here when last character in output
* buffer is not a newline.
*/
/* Assure space for NULL */
}
if (rv != APR_SUCCESS)
return rv;
}
return APR_SUCCESS;
}
/*
* execute
*/
{
}
char *p1;
char *p2;
int c;
if (p1) {
p1 = 0;
c = (unsigned char)p2[1];
goto yes;
continue;
}
}
}
goto yes;
continue;
}
c = (unsigned char)p1[1];
goto yes;
continue;
}
if (p2)
if (p2)
} else {
goto yes;
continue;
}
}
continue;
}
yes:
if (rv != APR_SUCCESS)
return rv;
return APR_SUCCESS;
return APR_SUCCESS;
break;
break;
}
} else
}
if (rv != APR_SUCCESS)
return rv;
}
return rv;
}
/*
* match
*/
{
char *p1;
int circf;
if(gf) {
if(*expbuf) return(0);
} else {
}
}
/*
* substitute
*/
{
return -1;
return -1;
}
}
}
/*
* dosub
*/
{
int c;
if(n > 0 && n < 999) {
}
while ((c = *rp++) != 0) {
if (c == '&') {
return APR_EGENERAL;
}
else if (c == '\\') {
c = *rp++;
return APR_EGENERAL;
}
else
*sp++ = c;
} else
*sp++ = c;
/* expand genbuf and set the sp appropriately */
}
}
return rv;
}
/*
* place
*/
{
}
return sp + n;
}
/*
* command
*/
{
int i;
int length;
case ACOM:
} else {
}
break;
case CCOM:
;
}
break;
case DCOM:
break;
case CDCOM:
while(*p1 != '\n') {
if(*p1++ == 0) {
return APR_SUCCESS;
}
}
p1++;
break;
case EQCOM:
break;
case GCOM:
break;
case CGCOM:
break;
case HCOM:
break;
case CHCOM:
break;
case ICOM:
break;
case BCOM:
break;
case LCOM:
while(*p1)
if((unsigned char)*p1 >= 040) {
if(*p1 == 0177) {
*p2 = '\\';
if (rv != APR_SUCCESS)
return rv;
}
p2--;
p1++;
continue;
}
*p2++ = '\\';
*p2 = '\\';
if (rv != APR_SUCCESS)
return rv;
}
*p2 = '\\';
if (rv != APR_SUCCESS)
return rv;
}
*p2 = '\\';
if (rv != APR_SUCCESS)
return rv;
}
*p2 = '\\';
if (rv != APR_SUCCESS)
return rv;
}
} else {
*p2 = '\\';
if (rv != APR_SUCCESS)
return rv;
}
}
} else {
*p2 = '\\';
if (rv != APR_SUCCESS)
return rv;
}
p2--;
p1++;
}
*p2 = 0;
break;
case NCOM:
if (rv != APR_SUCCESS)
return rv;
}
if (rv != APR_SUCCESS)
return rv;
}
break;
case CNCOM:
if (rv != APR_SUCCESS)
return rv;
}
break;
case PCOM:
break;
case CPCOM:
break;
case QCOM:
if (rv != APR_SUCCESS)
break;
}
if (rv != APR_SUCCESS)
return rv;
}
break;
case RCOM:
} else {
}
break;
case SCOM:
if (i == -1) {
return APR_EGENERAL;
}
if (rv != APR_SUCCESS)
return rv;
} else {
if (rv != APR_SUCCESS)
return rv;
}
}
break;
case TCOM:
break;
case WCOM:
break;
case XCOM:
break;
case YCOM:
break;
}
return rv;
}
/*
* arout
*/
{
char *p1;
if (rv != APR_SUCCESS)
return rv;
} else {
char buf[512];
apr_size_t n = sizeof(buf);
!= APR_SUCCESS)
continue;
if (n == 0)
break;
if (rv != APR_SUCCESS) {
return rv;
}
n = sizeof(buf);
}
}
}
return rv;
}
/*
* wline
*/
{
if (rv != APR_SUCCESS)
return rv;
return rv;
}