2 * libhfs - library for reading and writing Macintosh HFS volumes
3 * Copyright (C) 1996-1998 Robert Leslie
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 * $Id: node.c,v 1.9 1998/11/02 22:09:05 rob Exp $
30 * NAME: node->search()
31 * DESCRIPTION: locate a record in a node, or the record it should follow
33 int n_search(node *np, const byte *pkey)
35 const btree *bt = np->bt;
36 byte key1[HFS_MAX_KEYLEN], key2[HFS_MAX_KEYLEN];
39 bt->keyunpack(pkey, key2);
41 for (i = np->nd.ndNRecs; i--; )
45 rec = HFS_NODEREC(*np, i);
47 if (HFS_RECKEYLEN(rec) == 0)
48 continue; /* deleted record */
50 bt->keyunpack(rec, key1);
51 comp = bt->keycompare(key1, key2);