kernel: new DEBUG_RACE option. try to provoke race conditions between processes.
[minix.git] / commands / yap / machine.h
blob31c19443ffe9bf2da02811c570c6535428150bc0
1 /* Copyright (c) 1985 Ceriel J.H. Jacobs */
3 /* $Header$ */
5 # ifndef _MACHINE_
6 # define PUBLIC extern
7 # else
8 # define PUBLIC
9 # endif
12 * Simple minded finite state machine implementation to recognize
13 * strings.
16 struct state {
17 char s_char; /* character to match with */
18 char s_endstate; /* flag, 1 if this state is an endstate */
19 struct state *s_match; /* new state if matched */
20 struct state *s_next; /* other characters to match with */
21 short s_cnt; /* if an endstate, this field is filled with
22 * some info, dependant on the machine.
26 # define FSM_OKE 0
27 # define FSM_ISPREFIX -1 /* Must be < 0 */
28 # define FSM_HASPREFIX 1
30 int addstring();
32 * int addstring(str,cnt,mach)
33 * char *str; The string to be recognized
34 * int cnt; Attribute of the string.
35 * struct state **mach; The finite state machine
37 * This routine adds a string to a finite state automaton.
38 * It returns FSM_ISPREFIX if the added string is a prefix of a string already
39 * in the automaton, FSM_HASPREFIX if a string, already recognized by the
40 * automaton, is a prefix of the added string.
41 * Otherwise it returns FSM_OKE.
44 int match();
46 * int match(str,p_int,mach)
47 * char *str; pointer to string
48 * int *p_int; Pointer to an integer
49 * struct state *mach; The finite state machine
51 * A match of the string indicated by "str" is tried. If a head of "str"
52 * is recognized by the finite state automaton, a machine dependant number
53 * is put in the integer pointed to by "p_int".
54 * The number of characters that match is returned, so a return value of 0
55 * means no match.
56 * A return value of FSM_PREFIX means that the string "str" was a prefix of a
57 * matched string.
60 # undef PUBLIC