1 /* 2 * Copyright 1997, 2003 EPIC Software Labs. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notices, the above paragraph (the one permitting redistribution), 12 * this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The names of the author(s) may not be used to endorse or promote 15 * products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31 #ifndef __WORDS_H__ 32 #define __WORDS_H__ 33 34 /* From words.c */ 35 #define SOS -32767 36 #define EOS 32767 37 38 /* 39 * These are the "extended" values, and determine whether move_word_rel 40 * and real_move_to_abs_word are to honor "double quoted words" or not. 41 */ 42 #define DWORD_NO 0 /* Never honor double quoted words */ 43 #define DWORD_YES 1 /* Always support */ 44 #define DWORD_EXTRACTW 2 /* Support only if /xdebug extractw */ 45 #define DWORD_DWORDS 3 /* Support only if /xdebug dword */ 46 47 char * search_for (char *, char **, char *, int); 48 ssize_t move_word_rel (Char *, Char **, int, int, Char *); 49 const char * real_move_to_abs_word (Char *, Char **, int, int, Char *); 50 #define move_to_abs_word(a, b, c) real_move_to_abs_word(a, b, c, DWORD_YES, "\""); 51 52 /* 53 * real_extract is used for word extraction functions where if 'firstword' 54 * is negative, it silently gets truncated up to 0. 55 * start The word list (value of $*) 56 * firstword The first word to extract 57 * lastword The final word to extract 58 * extended The type of words in this list. 59 */ 60 char * real_extract (char *, int, int, int); 61 62 /* 63 * real_extract2 is used for word extraction where if 'firstword' 64 * is negative, it is recalculated from the end of the string (ie -2 means 65 * to start 2 words from the end of the string) 66 * start The word list (value of $*) 67 * firstword The first word to extract (negative counts from end) 68 * secondword The final word to extract (negative counts from end) 69 * extended The type of words in this list 70 */ 71 char * real_extract2 (Char *, int, int, int); 72 73 /* 74 * Macros to extract UWORDS (double quoted words never supported) 75 */ 76 #define extract(a, b, c) real_extract(a, b, c, DWORD_NO) 77 #define extract2(a, b, c) real_extract2(a, b, c, DWORD_NO) 78 #define next_arg(a, b) universal_next_arg_count((a),(b),1,DWORD_NO,0,"\"") 79 #define next_arg_count(a, b, c) universal_next_arg_count((a),(b),(c),DWORD_NO,0,"\"") 80 81 /* 82 * Macros to extract DWORDS (double quoted words always supported) 83 */ 84 #define extractdw(a, b, c) real_extract(a, b, c, DWORD_YES) 85 #define extractdw2(a, b, c) real_extract2(a, b, c, DWORD_YES) 86 #define new_next_arg(a, b) universal_next_arg_count((a),(b),1,DWORD_YES,1,"\"") 87 #define new_next_arg_count(a, b, c) universal_next_arg_count((a),(b),(c),DWORD_YES,0,"\"") 88 89 /* 90 * Macros to extract DWORDS FROM $* (depends on /xdebug extractw) 91 */ 92 #define extractew(a, b, c) real_extract(a, b, c, DWORD_EXTRACTW) 93 #define extractew2(a, b, c) real_extract2(a, b, c, DWORD_EXTRACTW) 94 #define next_earg(a, b) universal_next_arg_count((a),(b),1,DWORD_EXTRACTW,-1,"\"") 95 96 /* 97 * Macros to extract DWORDS FROM FUNCTIONS (depends on /xdebug dword) 98 */ 99 #define extractfw(a, b, c) real_extract(a, b, c, DWORD_DWORDS) 100 #define extractfw2(a, b, c) real_extract2(a, b, c, DWORD_DWORDS) 101 #define next_func_arg(a, b) universal_next_arg_count((a),(b),1,DWORD_DWORDS,-1,"\"") 102 103 int count_words (Char *str, int extended, Char *quotes); 104 105 #endif 106