Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / tok822_find.c
blob8e7e2b525c645007cd5e8828693870f9c278a479
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* tok822_find 3
6 /* SUMMARY
7 /* token list search operators
8 /* SYNOPSIS
9 /* #include <tok822.h>
11 /* TOK822 *tok822_find_type(head, type)
12 /* TOK822 *head;
13 /* int type;
15 /* TOK822 *tok822_rfind_type(tail, type)
16 /* TOK822 *tail;
17 /* int type;
18 /* DESCRIPTION
19 /* This module implements token list search operations.
21 /* tok822_find_type() searches a list of tokens for the first
22 /* instance of the specified token type. The result is the
23 /* found token or a null pointer when the search failed.
25 /* tok822_rfind_type() searches a list of tokens in reverse direction
26 /* for the first instance of the specified token type. The result
27 /* is the found token or a null pointer when the search failed.
28 /* LICENSE
29 /* .ad
30 /* .fi
31 /* The Secure Mailer license must be distributed with this software.
32 /* AUTHOR(S)
33 /* Wietse Venema
34 /* IBM T.J. Watson Research
35 /* P.O. Box 704
36 /* Yorktown Heights, NY 10598, USA
37 /*--*/
39 /* System library. */
41 #include <sys_defs.h>
43 /* Utility library. */
45 #include <vstring.h>
47 /* Global library. */
49 #include <tok822.h>
51 /* tok822_find_type - find specific token type, forward search */
53 TOK822 *tok822_find_type(TOK822 *head, int op)
55 TOK822 *tp;
57 for (tp = head; tp != 0 && tp->type != op; tp = tp->next)
58 /* void */ ;
59 return (tp);
62 /* tok822_rfind_type - find specific token type, backward search */
64 TOK822 *tok822_rfind_type(TOK822 *tail, int op)
66 TOK822 *tp;
68 for (tp = tail; tp != 0 && tp->type != op; tp = tp->prev)
69 /* void */ ;
70 return (tp);