1 /* $NetBSD: tok822_find.c,v 1.1.1.1 2009/06/23 10:08:48 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* tok822_find 3 6 /* SUMMARY 7 /* token list search operators 8 /* SYNOPSIS 9 /* #include <tok822.h> 10 /* 11 /* TOK822 *tok822_find_type(head, type) 12 /* TOK822 *head; 13 /* int type; 14 /* 15 /* TOK822 *tok822_rfind_type(tail, type) 16 /* TOK822 *tail; 17 /* int type; 18 /* DESCRIPTION 19 /* This module implements token list search operations. 20 /* 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. 24 /* 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 /*--*/ 38 39 /* System library. */ 40 41 #include <sys_defs.h> 42 43 /* Utility library. */ 44 45 #include <vstring.h> 46 47 /* Global library. */ 48 49 #include <tok822.h> 50 51 /* tok822_find_type - find specific token type, forward search */ 52 53 TOK822 *tok822_find_type(TOK822 *head, int op) 54 { 55 TOK822 *tp; 56 57 for (tp = head; tp != 0 && tp->type != op; tp = tp->next) 58 /* void */ ; 59 return (tp); 60 } 61 62 /* tok822_rfind_type - find specific token type, backward search */ 63 64 TOK822 *tok822_rfind_type(TOK822 *tail, int op) 65 { 66 TOK822 *tp; 67 68 for (tp = tail; tp != 0 && tp->type != op; tp = tp->prev) 69 /* void */ ; 70 return (tp); 71 } 72