components/apache2/mod_sed/sed0.c
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Wed, 29 Aug 2012 11:05:56 -0700
changeset 957 255465c5756f
parent 278 77b380ba9d84
permissions -rw-r--r--
Close of build 04.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
278
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     1
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     2
 * Copyright (c) 2005, 2008 Sun Microsystems, Inc. All Rights Reserved.
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     3
 * Use is subject to license terms.
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     4
 *
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     5
 *	Copyright (c) 1984 AT&T
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     6
 *	  All Rights Reserved  	
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     7
 *
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     8
 * Licensed under the Apache License, Version 2.0 (the "License");
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
     9
 * you may not use this file except in compliance with the License.
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    10
 * You may obtain a copy of the License at
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    11
 *  http://www.apache.org/licenses/LICENSE-2.0. 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    12
 * 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    13
 * Unless required by applicable law or agreed to in writing, software 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    14
 * distributed under the License is distributed on an "AS IS" BASIS, 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    16
 * or implied. 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    17
 * See the License for the specific language governing permissions and
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    18
 * limitations under the License. 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    19
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    20
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    21
#include "apr.h"
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    22
#include "apr_strings.h"
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    23
#include "libsed.h"
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    24
#include "sed.h"
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    25
#include "regexp.h"
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    26
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    27
#define CCEOF 22
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    28
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    29
static int fcomp(sed_commands_t *commands, apr_file_t *fin);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    30
static char *compsub(sed_commands_t *commands,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    31
                     sed_comp_args *compargs, char *rhsbuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    32
static int rline(sed_commands_t *commands, apr_file_t *fin,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    33
                 char *lbuf, char *lbend);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    34
static char *address(sed_commands_t *commands, char *expbuf,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    35
                     apr_status_t* status);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    36
static char *text(sed_commands_t *commands, char *textbuf, char *endbuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    37
static sed_label_t *search(sed_commands_t *commands);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    38
static char *ycomp(sed_commands_t *commands, char *expbuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    39
static char *comple(sed_commands_t *commands, sed_comp_args *compargs,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    40
                    char *x1, char *ep, char *x3, char x4);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    41
static sed_reptr_t *alloc_reptr(sed_commands_t *commands);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    42
static int check_finalized(const sed_commands_t *commands);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    43
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    44
void command_errf(sed_commands_t *commands, const char *fmt, ...)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    45
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    46
    if (commands->errfn && commands->pool) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    47
        va_list args;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    48
        const char* error;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    49
        va_start(args, fmt);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    50
        error = apr_pvsprintf(commands->pool, fmt, args);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    51
        commands->errfn(commands->data, error);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    52
        va_end(args);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    53
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    54
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    55
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    56
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    57
 * sed_init_commands
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    58
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    59
apr_status_t sed_init_commands(sed_commands_t *commands, sed_err_fn_t *errfn, void *data,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    60
                               apr_pool_t *p)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    61
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    62
    memset(commands, 0, sizeof(*commands));
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    63
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    64
    commands->errfn = errfn;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    65
    commands->data = data;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    66
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    67
    commands->labtab = commands->ltab;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    68
    commands->lab = commands->labtab + 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    69
    commands->pool = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    70
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    71
    commands->respace = apr_pcalloc(p, RESIZE);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    72
    if (commands->respace == NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    73
        command_errf(commands, SEDERR_OOMMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    74
        return APR_EGENERAL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    75
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    76
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    77
    commands->rep = alloc_reptr(commands);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    78
    if (commands->rep == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    79
        return APR_EGENERAL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    80
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    81
    commands->rep->ad1 = commands->respace;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    82
    commands->reend = &commands->respace[RESIZE - 1];
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    83
    commands->labend = &commands->labtab[SED_LABSIZE];
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    84
    commands->canbefinal = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    85
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    86
    return APR_SUCCESS;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    87
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    88
 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    89
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    90
 * sed_destroy_commands
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    91
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    92
void sed_destroy_commands(sed_commands_t *commands)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    93
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    94
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    95
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    96
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    97
 * sed_compile_string
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    98
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
    99
apr_status_t sed_compile_string(sed_commands_t *commands, const char *s)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   100
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   101
    apr_status_t rv;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   102
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   103
    commands->earg = s;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   104
    commands->eflag = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   105
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   106
    rv = fcomp(commands, NULL);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   107
    if (rv == APR_SUCCESS)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   108
        commands->canbefinal = check_finalized(commands);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   109
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   110
    commands->eflag = 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   111
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   112
    return (rv != 0 ? APR_EGENERAL : APR_SUCCESS);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   113
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   114
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   115
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   116
 * sed_compile_file
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   117
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   118
apr_status_t sed_compile_file(sed_commands_t *commands, apr_file_t *fin)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   119
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   120
    apr_status_t rv = fcomp(commands, fin);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   121
    return (rv != 0 ? APR_EGENERAL : APR_SUCCESS);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   122
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   123
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   124
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   125
 * sed_get_finalize_error
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   126
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   127
char* sed_get_finalize_error(const sed_commands_t *commands, apr_pool_t* pool)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   128
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   129
    const sed_label_t *lab;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   130
    if (commands->depth) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   131
        return SEDERR_TMOMES;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   132
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   133
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   134
    /* Empty branch chain is not a issue */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   135
    for (lab = commands->labtab + 1; lab < commands->lab; lab++) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   136
        char *error;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   137
        if (lab->address == 0) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   138
            error = apr_psprintf(pool, SEDERR_ULMES, lab->asc);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   139
            return error;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   140
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   141
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   142
        if (lab->chain) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   143
            return SEDERR_INTERNAL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   144
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   145
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   146
    return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   147
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   148
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   149
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   150
 * sed_canbe_finalized
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   151
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   152
int sed_canbe_finalized(const sed_commands_t *commands)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   153
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   154
    return commands->canbefinal;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   155
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   156
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   157
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   158
 * check_finalized
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   159
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   160
static int check_finalized(const sed_commands_t *commands)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   161
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   162
    const sed_label_t *lab;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   163
    if (commands->depth) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   164
        return 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   165
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   166
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   167
    /* Empty branch chain is not a issue */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   168
    for (lab = commands->labtab + 1; lab < commands->lab; lab++) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   169
        if (lab->address == 0 || (lab->chain)) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   170
            return 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   171
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   172
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   173
    return 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   174
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   175
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   176
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   177
 * dechain
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   178
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   179
static void dechain(sed_label_t *lpt, sed_reptr_t *address)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   180
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   181
    sed_reptr_t *rep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   182
    if ((lpt == NULL) || (lpt->chain == NULL) || (address == NULL))
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   183
        return;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   184
    rep = lpt->chain;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   185
    while (rep->lb1) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   186
        sed_reptr_t *next;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   187
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   188
        next = rep->lb1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   189
        rep->lb1 = address;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   190
        rep = next;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   191
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   192
    rep->lb1 = address;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   193
    lpt->chain = NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   194
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   195
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   196
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   197
 * fcomp
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   198
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   199
static int fcomp(sed_commands_t *commands, apr_file_t *fin)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   200
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   201
    char *p, *op, *tp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   202
    sed_reptr_t *pt, *pt1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   203
    int i, ii;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   204
    sed_label_t *lpt;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   205
    char fnamebuf[APR_PATH_MAX];
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   206
    apr_status_t status;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   207
    sed_comp_args compargs;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   208
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   209
    op = commands->lastre;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   210
    if (!commands->linebuf) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   211
        commands->linebuf = apr_pcalloc(commands->pool, LBSIZE + 1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   212
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   213
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   214
    if (rline(commands, fin, commands->linebuf,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   215
              (commands->linebuf + LBSIZE + 1)) < 0)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   216
        return 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   217
    if (*commands->linebuf == '#') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   218
        if (commands->linebuf[1] == 'n')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   219
            commands->nflag = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   220
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   221
    else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   222
        commands->cp = commands->linebuf;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   223
        goto comploop;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   224
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   225
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   226
    for (;;) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   227
        if (rline(commands, fin, commands->linebuf,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   228
                  (commands->linebuf + LBSIZE + 1)) < 0)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   229
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   230
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   231
        commands->cp = commands->linebuf;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   232
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   233
comploop:
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   234
        while (*commands->cp == ' ' || *commands->cp == '\t')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   235
            commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   236
        if (*commands->cp == '\0' || *commands->cp == '#')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   237
            continue;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   238
        if (*commands->cp == ';') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   239
            commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   240
            goto comploop;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   241
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   242
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   243
        p = address(commands, commands->rep->ad1, &status);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   244
        if (status != APR_SUCCESS) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   245
            command_errf(commands, SEDERR_CGMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   246
            return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   247
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   248
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   249
        if (p == commands->rep->ad1) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   250
            if (op)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   251
                commands->rep->ad1 = op;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   252
            else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   253
                command_errf(commands, SEDERR_NRMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   254
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   255
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   256
        } else if (p == 0) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   257
            p = commands->rep->ad1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   258
            commands->rep->ad1 = 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   259
        } else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   260
            op = commands->rep->ad1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   261
            if (*commands->cp == ',' || *commands->cp == ';') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   262
                commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   263
                commands->rep->ad2 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   264
                p = address(commands, commands->rep->ad2, &status);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   265
                if ((status != APR_SUCCESS) || (p == 0)) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   266
                    command_errf(commands, SEDERR_CGMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   267
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   268
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   269
                if (p == commands->rep->ad2)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   270
                    commands->rep->ad2 = op;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   271
                else
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   272
                    op = commands->rep->ad2;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   273
            } else
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   274
                commands->rep->ad2 = 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   275
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   276
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   277
        if(p > &commands->respace[RESIZE-1]) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   278
            command_errf(commands, SEDERR_TMMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   279
            return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   280
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   281
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   282
        while (*commands->cp == ' ' || *commands->cp == '\t')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   283
            commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   284
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   285
swit:
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   286
        switch(*commands->cp++) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   287
        default:
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   288
            command_errf(commands, SEDERR_UCMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   289
            return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   290
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   291
        case '!':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   292
            commands->rep->negfl = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   293
            goto swit;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   294
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   295
        case '{':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   296
            commands->rep->command = BCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   297
            commands->rep->negfl = !(commands->rep->negfl);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   298
            commands->cmpend[commands->depth++] = &commands->rep->lb1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   299
            commands->rep = alloc_reptr(commands);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   300
            commands->rep->ad1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   301
            if (*commands->cp == '\0')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   302
                continue;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   303
            goto comploop;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   304
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   305
        case '}':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   306
            if (commands->rep->ad1) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   307
                command_errf(commands, SEDERR_AD0MES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   308
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   309
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   310
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   311
            if (--commands->depth < 0) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   312
                command_errf(commands, SEDERR_TMCMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   313
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   314
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   315
            *commands->cmpend[commands->depth] = commands->rep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   316
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   317
            commands->rep->ad1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   318
            continue;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   319
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   320
        case '=':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   321
            commands->rep->command = EQCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   322
            if (commands->rep->ad2) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   323
                command_errf(commands, SEDERR_AD1MES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   324
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   325
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   326
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   327
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   328
        case ':':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   329
            if (commands->rep->ad1) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   330
                command_errf(commands, SEDERR_AD0MES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   331
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   332
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   333
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   334
            while (*commands->cp++ == ' ');
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   335
            commands->cp--;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   336
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   337
            tp = commands->lab->asc;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   338
            while ((*tp++ = *commands->cp++)) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   339
                if (tp >= &(commands->lab->asc[8])) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   340
                    command_errf(commands, SEDERR_LTLMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   341
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   342
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   343
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   344
            *--tp = '\0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   345
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   346
            if ((lpt = search(commands)) != NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   347
                if (lpt->address) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   348
                    command_errf(commands, SEDERR_DLMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   349
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   350
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   351
                dechain(lpt, commands->rep);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   352
            } else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   353
                commands->lab->chain = 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   354
                lpt = commands->lab;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   355
                if (++commands->lab >= commands->labend) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   356
                    command_errf(commands, SEDERR_TMLMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   357
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   358
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   359
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   360
            lpt->address = commands->rep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   361
            commands->rep->ad1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   362
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   363
            continue;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   364
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   365
        case 'a':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   366
            commands->rep->command = ACOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   367
            if (commands->rep->ad2) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   368
                command_errf(commands, SEDERR_AD1MES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   369
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   370
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   371
            if (*commands->cp == '\\')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   372
                commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   373
            if (*commands->cp++ != '\n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   374
                command_errf(commands, SEDERR_CGMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   375
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   376
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   377
            commands->rep->re1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   378
            p = text(commands, commands->rep->re1, commands->reend);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   379
            if (p == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   380
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   381
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   382
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   383
        case 'c':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   384
            commands->rep->command = CCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   385
            if (*commands->cp == '\\') commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   386
            if (*commands->cp++ != ('\n')) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   387
                command_errf(commands, SEDERR_CGMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   388
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   389
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   390
            commands->rep->re1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   391
            p = text(commands, commands->rep->re1, commands->reend);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   392
            if (p == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   393
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   394
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   395
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   396
        case 'i':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   397
            commands->rep->command = ICOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   398
            if (commands->rep->ad2) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   399
                command_errf(commands, SEDERR_AD1MES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   400
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   401
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   402
            if (*commands->cp == '\\') commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   403
            if (*commands->cp++ != ('\n')) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   404
                command_errf(commands, SEDERR_CGMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   405
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   406
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   407
            commands->rep->re1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   408
            p = text(commands, commands->rep->re1, commands->reend);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   409
            if (p == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   410
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   411
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   412
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   413
        case 'g':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   414
            commands->rep->command = GCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   415
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   416
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   417
        case 'G':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   418
            commands->rep->command = CGCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   419
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   420
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   421
        case 'h':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   422
            commands->rep->command = HCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   423
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   424
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   425
        case 'H':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   426
            commands->rep->command = CHCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   427
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   428
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   429
        case 't':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   430
            commands->rep->command = TCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   431
            goto jtcommon;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   432
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   433
        case 'b':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   434
            commands->rep->command = BCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   435
jtcommon:
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   436
            while (*commands->cp++ == ' ');
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   437
            commands->cp--;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   438
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   439
            if (*commands->cp == '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   440
                if ((pt = commands->labtab->chain) != NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   441
                    while ((pt1 = pt->lb1) != NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   442
                        pt = pt1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   443
                    pt->lb1 = commands->rep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   444
                } else
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   445
                    commands->labtab->chain = commands->rep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   446
                break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   447
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   448
            tp = commands->lab->asc;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   449
            while ((*tp++ = *commands->cp++))
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   450
                if (tp >= &(commands->lab->asc[8])) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   451
                    command_errf(commands, SEDERR_LTLMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   452
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   453
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   454
            commands->cp--;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   455
            *--tp = '\0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   456
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   457
            if ((lpt = search(commands)) != NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   458
                if (lpt->address) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   459
                    commands->rep->lb1 = lpt->address;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   460
                } else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   461
                    pt = lpt->chain;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   462
                    while ((pt1 = pt->lb1) != NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   463
                        pt = pt1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   464
                    pt->lb1 = commands->rep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   465
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   466
            } else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   467
                commands->lab->chain = commands->rep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   468
                commands->lab->address = 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   469
                if (++commands->lab >= commands->labend) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   470
                    command_errf(commands, SEDERR_TMLMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   471
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   472
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   473
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   474
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   475
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   476
        case 'n':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   477
            commands->rep->command = NCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   478
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   479
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   480
        case 'N':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   481
            commands->rep->command = CNCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   482
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   483
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   484
        case 'p':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   485
            commands->rep->command = PCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   486
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   487
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   488
        case 'P':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   489
            commands->rep->command = CPCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   490
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   491
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   492
        case 'r':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   493
            commands->rep->command = RCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   494
            if (commands->rep->ad2) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   495
                command_errf(commands, SEDERR_AD1MES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   496
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   497
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   498
            if (*commands->cp++ != ' ') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   499
                command_errf(commands, SEDERR_CGMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   500
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   501
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   502
            commands->rep->re1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   503
            p = text(commands, commands->rep->re1, commands->reend);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   504
            if (p == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   505
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   506
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   507
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   508
        case 'd':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   509
            commands->rep->command = DCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   510
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   511
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   512
        case 'D':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   513
            commands->rep->command = CDCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   514
            commands->rep->lb1 = commands->ptrspace;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   515
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   516
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   517
        case 'q':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   518
            commands->rep->command = QCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   519
            if (commands->rep->ad2) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   520
                command_errf(commands, SEDERR_AD1MES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   521
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   522
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   523
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   524
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   525
        case 'l':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   526
            commands->rep->command = LCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   527
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   528
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   529
        case 's':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   530
            commands->rep->command = SCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   531
            commands->sseof = *commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   532
            commands->rep->re1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   533
            p = comple(commands, &compargs, (char *) 0, commands->rep->re1,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   534
                       commands->reend, commands->sseof);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   535
            if (p == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   536
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   537
            if (p == commands->rep->re1) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   538
                if (op)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   539
                    commands->rep->re1 = op;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   540
                else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   541
                    command_errf(commands, SEDERR_NRMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   542
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   543
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   544
            } else 
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   545
                op = commands->rep->re1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   546
            commands->rep->rhs = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   547
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   548
            p = compsub(commands, &compargs, commands->rep->rhs);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   549
            if ((p) == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   550
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   551
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   552
            if (*commands->cp == 'g') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   553
                commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   554
                commands->rep->gfl = 999;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   555
            } else if (commands->gflag)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   556
                commands->rep->gfl = 999;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   557
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   558
            if (*commands->cp >= '1' && *commands->cp <= '9') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   559
                i = *commands->cp - '0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   560
                commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   561
                while (1) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   562
                    ii = *commands->cp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   563
                    if (ii < '0' || ii > '9')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   564
                        break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   565
                    i = i*10 + ii - '0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   566
                    if (i > 512) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   567
                        command_errf(commands, SEDERR_TOOBIG, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   568
                        return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   569
                    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   570
                    commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   571
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   572
                commands->rep->gfl = i;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   573
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   574
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   575
            if (*commands->cp == 'p') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   576
                commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   577
                commands->rep->pfl = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   578
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   579
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   580
            if (*commands->cp == 'P') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   581
                commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   582
                commands->rep->pfl = 2;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   583
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   584
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   585
            if (*commands->cp == 'w') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   586
                commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   587
                if (*commands->cp++ !=  ' ') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   588
                    command_errf(commands, SEDERR_SMMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   589
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   590
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   591
                if (text(commands, fnamebuf, &fnamebuf[APR_PATH_MAX]) == NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   592
                    command_errf(commands, SEDERR_FNTL, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   593
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   594
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   595
                for (i = commands->nfiles - 1; i >= 0; i--)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   596
                    if (strcmp(fnamebuf,commands->fname[i]) == 0) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   597
                        commands->rep->findex = i;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   598
                        goto done;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   599
                    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   600
                if (commands->nfiles >= NWFILES) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   601
                    command_errf(commands, SEDERR_TMWFMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   602
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   603
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   604
                commands->fname[commands->nfiles] =
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   605
                            apr_pstrdup(commands->pool, fnamebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   606
                if (commands->fname[commands->nfiles] == NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   607
                    command_errf(commands, SEDERR_OOMMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   608
                    return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   609
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   610
                commands->rep->findex = commands->nfiles++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   611
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   612
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   613
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   614
        case 'w':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   615
            commands->rep->command = WCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   616
            if (*commands->cp++ != ' ') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   617
                command_errf(commands, SEDERR_SMMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   618
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   619
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   620
            if (text(commands, fnamebuf, &fnamebuf[APR_PATH_MAX]) == NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   621
                command_errf(commands, SEDERR_FNTL, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   622
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   623
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   624
            for (i = commands->nfiles - 1; i >= 0; i--)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   625
                if (strcmp(fnamebuf, commands->fname[i]) == 0) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   626
                    commands->rep->findex = i;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   627
                    goto done;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   628
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   629
            if (commands->nfiles >= NWFILES) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   630
                command_errf(commands, SEDERR_TMWFMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   631
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   632
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   633
            if ((commands->fname[commands->nfiles] =
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   634
                        apr_pstrdup(commands->pool, fnamebuf)) == NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   635
                command_errf(commands, SEDERR_OOMMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   636
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   637
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   638
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   639
            commands->rep->findex = commands->nfiles++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   640
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   641
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   642
        case 'x':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   643
            commands->rep->command = XCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   644
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   645
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   646
        case 'y':
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   647
            commands->rep->command = YCOM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   648
            commands->sseof = *commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   649
            commands->rep->re1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   650
            p = ycomp(commands, commands->rep->re1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   651
            if (p == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   652
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   653
            break;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   654
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   655
done:
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   656
        commands->rep = alloc_reptr(commands);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   657
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   658
        commands->rep->ad1 = p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   659
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   660
        if (*commands->cp++ != '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   661
            if (commands->cp[-1] == ';')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   662
                goto comploop;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   663
            command_errf(commands, SEDERR_CGMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   664
            return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   665
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   666
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   667
    commands->rep->command = 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   668
    commands->lastre = op;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   669
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   670
    return 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   671
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   672
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   673
static char *compsub(sed_commands_t *commands,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   674
                     sed_comp_args *compargs, char *rhsbuf)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   675
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   676
    char   *p, *q;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   677
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   678
    p = rhsbuf;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   679
    q = commands->cp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   680
    for(;;) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   681
        if(p > &commands->respace[RESIZE-1]) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   682
            command_errf(commands, SEDERR_TMMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   683
            return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   684
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   685
        if((*p = *q++) == '\\') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   686
            p++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   687
            if(p > &commands->respace[RESIZE-1]) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   688
                command_errf(commands, SEDERR_TMMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   689
                return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   690
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   691
            *p = *q++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   692
            if(*p > compargs->nbra + '0' && *p <= '9') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   693
                command_errf(commands, SEDERR_DOORNG, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   694
                return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   695
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   696
            p++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   697
            continue;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   698
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   699
        if(*p == commands->sseof) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   700
            *p++ = '\0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   701
            commands->cp = q;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   702
            return(p);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   703
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   704
          if(*p++ == '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   705
            command_errf(commands, SEDERR_EDMOSUB, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   706
            return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   707
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   708
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   709
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   710
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   711
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   712
 * rline
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   713
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   714
static int rline(sed_commands_t *commands, apr_file_t *fin,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   715
                 char *lbuf, char *lbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   716
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   717
    char   *p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   718
    const char *q;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   719
    int    t;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   720
    apr_size_t bytes_read;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   721
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   722
    p = lbuf;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   723
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   724
    if(commands->eflag) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   725
        if(commands->eflag > 0) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   726
            commands->eflag = -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   727
            q = commands->earg;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   728
            while((t = *q++) != '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   729
                if(t == '\n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   730
                    commands->saveq = q;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   731
                    goto out1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   732
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   733
                if (p < lbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   734
                    *p++ = t;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   735
                if(t == '\\') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   736
                    if((t = *q++) == '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   737
                        commands->saveq = NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   738
                        return(-1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   739
                    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   740
                    if (p < lbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   741
                        *p++ = t;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   742
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   743
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   744
            commands->saveq = NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   745
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   746
        out1:
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   747
            if (p == lbend) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   748
                command_errf(commands, SEDERR_CLTL, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   749
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   750
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   751
            *p = '\0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   752
            return(1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   753
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   754
        if((q = commands->saveq) == 0)    return(-1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   755
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   756
        while((t = *q++) != '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   757
            if(t == '\n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   758
                commands->saveq = q;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   759
                goto out2;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   760
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   761
            if(p < lbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   762
                *p++ = t;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   763
            if(t == '\\') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   764
                if((t = *q++) == '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   765
                    commands->saveq = NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   766
                    return(-1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   767
                }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   768
                if (p < lbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   769
                    *p++ = t;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   770
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   771
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   772
        commands->saveq = NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   773
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   774
    out2:
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   775
        if (p == lbend) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   776
            command_errf(commands, SEDERR_CLTL, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   777
            return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   778
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   779
        *p = '\0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   780
        return(1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   781
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   782
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   783
    bytes_read = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   784
    /* XXX extremely inefficient 1 byte reads */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   785
    while (apr_file_read(fin, &t, &bytes_read) != APR_SUCCESS) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   786
        if(t == '\n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   787
            if (p == lbend) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   788
                command_errf(commands, SEDERR_CLTL, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   789
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   790
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   791
            *p = '\0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   792
            return(1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   793
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   794
        if (p < lbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   795
            *p++ = t;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   796
        if(t == '\\') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   797
            bytes_read = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   798
            if (apr_file_read(fin, &t, &bytes_read) != APR_SUCCESS) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   799
                return -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   800
            }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   801
            if(p < lbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   802
                *p++ = t;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   803
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   804
        bytes_read = 1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   805
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   806
    return(-1);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   807
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   808
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   809
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   810
 * address
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   811
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   812
static char *address(sed_commands_t *commands, char *expbuf,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   813
                     apr_status_t* status)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   814
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   815
    char   *rcp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   816
    apr_int64_t lno;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   817
    sed_comp_args compargs;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   818
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   819
    *status = APR_SUCCESS;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   820
    if(*commands->cp == '$') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   821
        if (expbuf > &commands->respace[RESIZE-2]) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   822
            command_errf(commands, SEDERR_TMMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   823
            *status = APR_EGENERAL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   824
            return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   825
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   826
        commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   827
        *expbuf++ = CEND;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   828
        *expbuf++ = CCEOF;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   829
        return(expbuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   830
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   831
    if (*commands->cp == '/' || *commands->cp == '\\' ) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   832
        if ( *commands->cp == '\\' )
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   833
            commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   834
        commands->sseof = *commands->cp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   835
        return(comple(commands, &compargs, (char *) 0, expbuf, commands->reend,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   836
                      commands->sseof));
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   837
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   838
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   839
    rcp = commands->cp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   840
    lno = 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   841
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   842
    while(*rcp >= '0' && *rcp <= '9')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   843
        lno = lno*10 + *rcp++ - '0';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   844
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   845
    if(rcp > commands->cp) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   846
        if (expbuf > &commands->respace[RESIZE-3]) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   847
            command_errf(commands, SEDERR_TMMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   848
            *status = APR_EGENERAL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   849
            return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   850
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   851
        *expbuf++ = CLNUM;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   852
        *expbuf++ = commands->nlno;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   853
        commands->tlno[commands->nlno++] = lno;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   854
        if(commands->nlno >= SED_NLINES) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   855
            command_errf(commands, SEDERR_TMLNMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   856
            *status = APR_EGENERAL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   857
            return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   858
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   859
        *expbuf++ = CCEOF;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   860
        commands->cp = rcp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   861
        return(expbuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   862
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   863
    return(NULL);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   864
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   865
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   866
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   867
 * text
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   868
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   869
static char *text(sed_commands_t *commands, char *textbuf, char *tbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   870
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   871
    char   *p, *q;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   872
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   873
    p = textbuf;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   874
    q = commands->cp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   875
#ifndef S5EMUL
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   876
    /*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   877
     * Strip off indentation from text to be inserted.
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   878
     */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   879
    while(*q == '\t' || *q == ' ')    q++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   880
#endif
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   881
    for(;;) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   882
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   883
        if(p > tbend)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   884
            return(NULL);    /* overflowed the buffer */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   885
        if((*p = *q++) == '\\')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   886
            *p = *q++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   887
        if(*p == '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   888
            commands->cp = --q;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   889
            return(++p);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   890
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   891
#ifndef S5EMUL
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   892
        /*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   893
         * Strip off indentation from text to be inserted.
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   894
         */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   895
        if(*p == '\n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   896
            while(*q == '\t' || *q == ' ')    q++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   897
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   898
#endif
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   899
        p++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   900
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   901
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   902
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   903
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   904
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   905
 * search
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   906
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   907
static sed_label_t *search(sed_commands_t *commands)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   908
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   909
    sed_label_t *rp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   910
    sed_label_t *ptr;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   911
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   912
    rp = commands->labtab;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   913
    ptr = commands->lab;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   914
    while (rp < ptr) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   915
        if (strcmp(rp->asc, ptr->asc) == 0)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   916
            return rp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   917
        rp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   918
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   919
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   920
    return 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   921
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   922
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   923
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   924
 * ycomp
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   925
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   926
static char *ycomp(sed_commands_t *commands, char *expbuf)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   927
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   928
    char    c;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   929
    int cint; /* integer value of char c */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   930
    char *ep, *tsp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   931
    int i;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   932
    char    *sp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   933
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   934
    ep = expbuf;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   935
    if(ep + 0377 > &commands->respace[RESIZE-1]) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   936
        command_errf(commands, SEDERR_TMMES, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   937
        return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   938
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   939
    sp = commands->cp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   940
    for(tsp = commands->cp; (c = *tsp) != commands->sseof; tsp++) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   941
        if(c == '\\')
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   942
            tsp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   943
        if(c == '\0' || c == '\n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   944
            command_errf(commands, SEDERR_EDMOSTR, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   945
            return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   946
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   947
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   948
    tsp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   949
    memset(ep, 0, 0400);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   950
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   951
    while((c = *sp++) != commands->sseof) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   952
        c &= 0377;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   953
        if(c == '\\' && *sp == 'n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   954
            sp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   955
            c = '\n';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   956
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   957
        cint = (int) c;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   958
        if((ep[cint] = *tsp++) == '\\' && *tsp == 'n') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   959
            ep[cint] = '\n';
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   960
            tsp++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   961
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   962
        if(ep[cint] == commands->sseof || ep[cint] == '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   963
            command_errf(commands, SEDERR_TSNTSS, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   964
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   965
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   966
    if(*tsp != commands->sseof) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   967
        if(*tsp == '\0') {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   968
            command_errf(commands, SEDERR_EDMOSTR, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   969
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   970
        else {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   971
            command_errf(commands, SEDERR_TSNTSS, commands->linebuf);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   972
        }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   973
        return NULL;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   974
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   975
    commands->cp = ++tsp;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   976
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   977
    for(i = 0; i < 0400; i++)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   978
        if(ep[i] == 0)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   979
            ep[i] = i;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   980
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   981
    return(ep + 0400);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   982
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   983
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   984
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   985
 * comple
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   986
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   987
static char *comple(sed_commands_t *commands, sed_comp_args *compargs,
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   988
                    char *x1, char *ep, char *x3, char x4)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   989
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   990
    char *p;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   991
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   992
    p = sed_compile(commands, compargs, ep + 1, x3, x4);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   993
    if(p == ep + 1)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   994
        return(ep);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   995
    *ep = compargs->circf;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   996
    return(p);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   997
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   998
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
   999
/*
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1000
 * alloc_reptr
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1001
 */
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1002
static sed_reptr_t *alloc_reptr(sed_commands_t *commands)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1003
{
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1004
    sed_reptr_t *var;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1005
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1006
    var = apr_pcalloc(commands->pool, sizeof(sed_reptr_t));
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1007
    if (var == NULL) {
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1008
        command_errf(commands, SEDERR_OOMMES);
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1009
        return 0;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1010
    }
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1011
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1012
    var->nrep = commands->nrep;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1013
    var->findex = -1;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1014
    commands->nrep++;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1015
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1016
    if (commands->ptrspace == NULL)
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1017
        commands->ptrspace = var;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1018
    else
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1019
        commands->ptrend->next = var;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1020
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1021
    commands->ptrend = var;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1022
    commands->labtab->address = var;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1023
    return var;
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1024
}
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1025
77b380ba9d84 7045614 Move Apache Web server to userland
Petr Sumbera <petr.sumbera@oracle.com>
parents:
diff changeset
  1026