f82568a780e35e8786958c49a1259434e2088b9cniq/*
f82568a780e35e8786958c49a1259434e2088b9cniq * Copyright (c) 2005, 2008 Sun Microsystems, Inc. All Rights Reserved.
f82568a780e35e8786958c49a1259434e2088b9cniq * Use is subject to license terms.
f82568a780e35e8786958c49a1259434e2088b9cniq *
11e076839c8d5a82d55e710194d0daac51390dbdsf * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
11e076839c8d5a82d55e710194d0daac51390dbdsf * All Rights Reserved
f82568a780e35e8786958c49a1259434e2088b9cniq *
f82568a780e35e8786958c49a1259434e2088b9cniq * University Copyright- Copyright (c) 1982, 1986, 1988
f82568a780e35e8786958c49a1259434e2088b9cniq * The Regents of the University of California
f82568a780e35e8786958c49a1259434e2088b9cniq * All Rights Reserved
f82568a780e35e8786958c49a1259434e2088b9cniq *
f82568a780e35e8786958c49a1259434e2088b9cniq * University Acknowledgment- Portions of this document are derived from
f82568a780e35e8786958c49a1259434e2088b9cniq * software developed by the University of California, Berkeley, and its
f82568a780e35e8786958c49a1259434e2088b9cniq * contributors.
f82568a780e35e8786958c49a1259434e2088b9cniq *
f82568a780e35e8786958c49a1259434e2088b9cniq * Licensed under the Apache License, Version 2.0 (the "License");
f82568a780e35e8786958c49a1259434e2088b9cniq * you may not use this file except in compliance with the License.
f82568a780e35e8786958c49a1259434e2088b9cniq * You may obtain a copy of the License at
742318b93e89c311f66b55f426c4d9cf2c14628bjim * http://www.apache.org/licenses/LICENSE-2.0.
742318b93e89c311f66b55f426c4d9cf2c14628bjim *
742318b93e89c311f66b55f426c4d9cf2c14628bjim * Unless required by applicable law or agreed to in writing, software
742318b93e89c311f66b55f426c4d9cf2c14628bjim * distributed under the License is distributed on an "AS IS" BASIS,
742318b93e89c311f66b55f426c4d9cf2c14628bjim * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
742318b93e89c311f66b55f426c4d9cf2c14628bjim * or implied.
f82568a780e35e8786958c49a1259434e2088b9cniq * See the License for the specific language governing permissions and
742318b93e89c311f66b55f426c4d9cf2c14628bjim * limitations under the License.
f82568a780e35e8786958c49a1259434e2088b9cniq */
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#ifndef _REGEXP_H
f82568a780e35e8786958c49a1259434e2088b9cniq#define _REGEXP_H
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#include "libsed.h"
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#ifdef __cplusplus
f82568a780e35e8786958c49a1259434e2088b9cniqextern "C" {
f82568a780e35e8786958c49a1259434e2088b9cniq#endif
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#define CBRA 2
f82568a780e35e8786958c49a1259434e2088b9cniq#define CCHR 4
f82568a780e35e8786958c49a1259434e2088b9cniq#define CDOT 8
f82568a780e35e8786958c49a1259434e2088b9cniq#define CCL 12
f82568a780e35e8786958c49a1259434e2088b9cniq#define CXCL 16
f82568a780e35e8786958c49a1259434e2088b9cniq#define CDOL 20
f82568a780e35e8786958c49a1259434e2088b9cniq#define CCEOF 22
f82568a780e35e8786958c49a1259434e2088b9cniq#define CKET 24
f82568a780e35e8786958c49a1259434e2088b9cniq#define CBACK 36
f82568a780e35e8786958c49a1259434e2088b9cniq#define NCCL 40
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#define STAR 01
f82568a780e35e8786958c49a1259434e2088b9cniq#define RNGE 03
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#define NBRA 9
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#define PLACE(c) ep[c >> 3] |= bittab[c & 07]
f82568a780e35e8786958c49a1259434e2088b9cniq#define ISTHERE(c) (ep[c >> 3] & bittab[c & 07])
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniqtypedef struct _step_vars_storage {
f82568a780e35e8786958c49a1259434e2088b9cniq char *loc1, *loc2, *locs;
f82568a780e35e8786958c49a1259434e2088b9cniq char *braslist[NBRA];
f82568a780e35e8786958c49a1259434e2088b9cniq char *braelist[NBRA];
f82568a780e35e8786958c49a1259434e2088b9cniq int low;
f82568a780e35e8786958c49a1259434e2088b9cniq int size;
f82568a780e35e8786958c49a1259434e2088b9cniq} step_vars_storage;
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniqtypedef struct _sed_comp_args {
f82568a780e35e8786958c49a1259434e2088b9cniq int circf; /* Regular expression starts with ^ */
f82568a780e35e8786958c49a1259434e2088b9cniq int nbra; /* braces count */
f82568a780e35e8786958c49a1259434e2088b9cniq} sed_comp_args;
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniqextern char *sed_compile(sed_commands_t *commands, sed_comp_args *compargs,
f82568a780e35e8786958c49a1259434e2088b9cniq char *ep, char *endbuf, int seof);
4c6374798c9e6c0fc3b42dbc5a7225f67d27cb9fjailletcextern void command_errf(sed_commands_t *commands, const char *fmt, ...)
4c6374798c9e6c0fc3b42dbc5a7225f67d27cb9fjailletc __attribute__((format(printf,2,3)));
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_CGMES "command garbled: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_SMMES "Space missing before filename: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMMES "too much command text: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_LTLMES "label too long: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_ULMES "undefined label: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_DLMES "duplicate labels: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMLMES "too many labels: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_AD0MES "no addresses allowed: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_AD1MES "only one address allowed: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TOOBIG "suffix too large: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_OOMMES "out of memory"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_COPFMES "cannot open pattern file: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_COIFMES "cannot open input file: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMOMES "too many {'s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMCMES "too many }'s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_NRMES "first RE may not be null"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_UCMES "unrecognized command: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMWFMES "too many files in w commands"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_COMES "cannot open %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_CCMES "cannot create %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMLNMES "too many line numbers"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMAMES "too many appends after line %lld"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TMRMES "too many reads after line %lld"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_DOORNG "``\\digit'' out of range: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_EDMOSUB "ending delimiter missing on substitution: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_EDMOSTR "ending delimiter missing on string: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_FNTL "file name too long: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_CLTL "command line too long"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_TSNTSS "transform strings not the same size: %s"
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_OLTL "output line too long."
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_HSOVERFLOW "hold space overflowed."
f82568a780e35e8786958c49a1259434e2088b9cniq#define SEDERR_INTERNAL "internal sed error"
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#ifdef __cplusplus
f82568a780e35e8786958c49a1259434e2088b9cniq}
f82568a780e35e8786958c49a1259434e2088b9cniq#endif
f82568a780e35e8786958c49a1259434e2088b9cniq
f82568a780e35e8786958c49a1259434e2088b9cniq#endif /* _REGEXP_H */