1 /* 2 * Motif 3 * 4 * Copyright (c) 1987-2012, The Open Group. All rights reserved. 5 * 6 * These libraries and programs are free software; you can 7 * redistribute them and/or modify them under the terms of the GNU 8 * Lesser General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * These libraries and programs are distributed in the hope that 13 * they will be useful, but WITHOUT ANY WARRANTY; without even the 14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 * PURPOSE. See the GNU Lesser General Public License for more 16 * details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with these librararies and programs; if not, write 20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 21 * Floor, Boston, MA 02110-1301 USA 22 * 23 */ 24 #include <Xm/Picture.h> 25 26 #define NUMDIGIT '#' 27 #define HEXDIGIT 'x' 28 #define OCTALDIGIT 'o' 29 #define NONCASELETTER '?' 30 #define UPCASELETTER '&' 31 #define NONCASECHAR '@' 32 #define UPCASECHAR '!' 33 #define ESCAPE ';' 34 #define CLOSURE '*' 35 #define LBRACKET '[' 36 #define RBRACKET ']' 37 #define LBRACE '{' 38 #define RBRACE '}' 39 #define ALTERNATIVE ',' 40 41 #define NODE_START_COUNT 40 42 43 typedef enum { 44 NullTransition, /* Transition on no input */ 45 NumericDigit, /* eqivalent to [0-9] */ 46 HexDigit, /* eqivalent to [0-9a-fA-F] */ 47 OctalDigit, /* eqivalent to [0-7] */ 48 AnyLetter, /* [a-zA-Z] */ 49 UpCaseLetter, /* ditto, but translates [a-zA-Z] -> [A-Z] */ 50 AnyCharacter, /* Any printing character */ 51 UpCaseCharacter, /* ditto, case transition as above */ 52 LiteralCharacter /* Single character */ 53 } XmTransType; 54 55 typedef struct _XmPictureTransition { 56 int destination; /* Node to transition to */ 57 XmTransType type; /* literal, null, upcasechar, etc... */ 58 char c; /* key -- used for literals */ 59 /* OR: count for closures */ 60 struct _XmPictureTransition *next; /* Next transition from our node */ 61 } XmPictureTransition; 62 63 typedef struct _XmPictureNode { 64 int index; 65 XmPictureTransition *transitions; 66 } XmPictureNode; 67 68 typedef struct _XmPictureRec { 69 char * source; /* string it was parsed from */ 70 int num_nodes; 71 int nodes_alloced; 72 int start_node; 73 int final_node; 74 XmPictureNode **nodes; /* array of nodes */ 75 } XmPictureRec; 76 77 typedef struct _XmPictureStateRec { 78 XmPictureRec *picture; 79 char *current_string; 80 char *append; 81 int statesize; 82 unsigned char *state; /* bitvector of states */ 83 unsigned char *newstate; /* scratch space for use in 84 transitions */ 85 char current; /* currently added character */ 86 Boolean upcase; 87 } XmPictureStateRec; 88 89 typedef struct _XmAutoFill { 90 char c; /* char to fill */ 91 Boolean reject; /* literal's didn't match: it's "right out" */ 92 Boolean digit; /* isdigit(c) must be true */ 93 Boolean upcase; /* isupper(c) must be true */ 94 Boolean letter; /* isalpha(c) must be true */ 95 Boolean hexdigit; /* isxdigit(c) must be true */ 96 Boolean octaldigit; /* must be 0-7 */ 97 } XmAutoFill; 98