]>
git.saurik.com Git - apple/libinfo.git/blob - lookup.subproj/lu_utils.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
25 * Useful macros and other stuff for generic lookups
26 * Copyright (C) 1989 by NeXT, Inc.
29 #import <netinfo/lookup_types.h>
30 #include <netinfo/ni.h>
33 extern mach_port_t _lu_port
;
34 extern unit
*_lookup_buf
;
35 extern int _lu_running(void);
37 int lookupd_query(ni_proplist
*l
, ni_proplist
***out
);
38 ni_proplist
*lookupd_make_query(char *cat
, char *fmt
, ...);
39 void ni_property_merge(ni_property
*a
, ni_property
*b
);
40 void ni_proplist_merge(ni_proplist
*a
, ni_proplist
*b
);
42 typedef enum lookup_state
{
47 #define SETSTATE(_lu_set, _old_set, state, stayopen) \
49 if (_lu_running()) { \
51 *state = LOOKUP_CACHE; \
54 *state = LOOKUP_FILE; \
58 #define SETSTATEVOID(_lu_set, _old_set, state) \
60 if (_lu_running()) { \
62 *state = LOOKUP_CACHE; \
65 *state = LOOKUP_FILE; \
69 #define INTSETSTATEVOID(_lu_set, _old_set, state) \
72 if (_lu_running()) { \
74 *state = LOOKUP_CACHE; \
76 result = _old_set(); \
77 *state = LOOKUP_FILE; \
82 #define UNSETSTATE(_lu_unset, _old_unset, state) \
84 if (_lu_running()) { \
89 *state = LOOKUP_CACHE; \
92 #define GETENT(_lu_get, _old_get, state, res_type) \
96 if (_lu_running()) { \
97 if (*state == LOOKUP_CACHE) { \
108 #define LOOKUP1(_lu_lookup, _old_lookup, arg, res_type) \
112 if (_lu_running()) { \
113 res = _lu_lookup(arg); \
115 res = _old_lookup(arg); \
120 #define LOOKUP2(_lu_lookup, _old_lookup, arg1, arg2, res_type) \
124 if (_lu_running()) { \
125 res = _lu_lookup(arg1, arg2); \
127 res = _old_lookup(arg1, arg2); \