1/*++
2/* NAME
3/*	tok822_find 3
4/* SUMMARY
5/*	token list search operators
6/* SYNOPSIS
7/*	#include <tok822.h>
8/*
9/*	TOK822	*tok822_find_type(head, type)
10/*	TOK822	*head;
11/*	int	type;
12/*
13/*	TOK822	*tok822_rfind_type(tail, type)
14/*	TOK822	*tail;
15/*	int	type;
16/* DESCRIPTION
17/*	This module implements token list search operations.
18/*
19/*	tok822_find_type() searches a list of tokens for the first
20/*	instance of the specified token type. The result is the
21/*	found token or a null pointer when the search failed.
22/*
23/*	tok822_rfind_type() searches a list of tokens in reverse direction
24/*	for the first instance of the specified token type. The result
25/*	is the found token or a null pointer when the search failed.
26/* LICENSE
27/* .ad
28/* .fi
29/*	The Secure Mailer license must be distributed with this software.
30/* AUTHOR(S)
31/*	Wietse Venema
32/*	IBM T.J. Watson Research
33/*	P.O. Box 704
34/*	Yorktown Heights, NY 10598, USA
35/*--*/
36
37/* System library. */
38
39#include <sys_defs.h>
40
41/* Utility library. */
42
43#include <vstring.h>
44
45/* Global library. */
46
47#include <tok822.h>
48
49/* tok822_find_type - find specific token type, forward search */
50
51TOK822 *tok822_find_type(TOK822 *head, int op)
52{
53    TOK822 *tp;
54
55    for (tp = head; tp != 0 && tp->type != op; tp = tp->next)
56	 /* void */ ;
57    return (tp);
58}
59
60/* tok822_rfind_type - find specific token type, backward search */
61
62TOK822 *tok822_rfind_type(TOK822 *tail, int op)
63{
64    TOK822 *tp;
65
66    for (tp = tail; tp != 0 && tp->type != op; tp = tp->prev)
67	 /* void */ ;
68    return (tp);
69}
70